Repository: facebookresearch/dynabench

Issue:
Feature Proposal: Sending a Task Proposal back to the owners with recommendations on how it could be improved.
Currently, admins have options to only accept or reject a Task Proposal. When a task is rejected, there could be an option to send a recommendation back to the individual who created the task, with some advice on how he could improve his next proposal/existing proposal. 

This would be highly beneficial to individuals creating tasks who get rejections without knowing the reason behind it



Discussion:
### The frontend:

1. When an admin is reviewing a task proposal, he has two options. To either accept or reject the proposal.
2. How we can proceed in the frontend:
    1. We have another button called "Request Changes". On clicking this button, another modal opens up where the admin can type in their recommendations in a textarea element and submit those. 
    2. The user who submitted the task proposal can now view his proposal and see a new field in the proposal modal called "Changes". After seeing these changes, the user can edit his existing proposal and submit it again. This process can keep going back and forth as many times as required until the admin approves the task proposal.
    3. With this method, the admin still has an option to reject the proposal without requesting any changes (for e.g, in case of spam task proposals, or task proposals for a task that already exists).

### The API

1. There can be another field added to the task proposal model in [https://github.com/facebookresearch/dynabench/blob/79981d543189d8b9a28adb8f17c0e2b07c5767cf/api/models/task_proposal.py#L10-L33](https://github.com/facebookresearch/dynabench/blob/79981d543189d8b9a28adb8f17c0e2b07c5767cf/api/models/task_proposal.py#L10-L33) for the "Changes" that a person requests.
2. The corresponding controllers for editing the "Changes" value in the task proposal could be added in [https://github.com/facebookresearch/dynabench/blob/79981d543189d8b9a28adb8f17c0e2b07c5767cf/api/controllers/tasks.py#L31-L142](https://github.com/facebookresearch/dynabench/blob/79981d543189d8b9a28adb8f17c0e2b07c5767cf/api/controllers/tasks.py#L31-L142)
This sounds great to me! We should probably send them an email? One thing I'm worried about is that "Request changes" suggests that people are able to change proposals, which I don't think they're able to do? Perhaps we can just have your suggested modal pop up when we Reject? (So we would have a "Reject and encourage to resubmit", basically)
> This sounds great to me! We should probably send them an email?

That sounds like a great idea!

> Perhaps we can just have your suggested modal pop up when we Reject? (So we would have a "Reject and encourage to resubmit", basically)

Could you please elaborate on this further? I didn't really understand what you meant 😅


You were suggesting to have a "Request changes" button. I am saying we should just Reject, but have an input field to explain why we reject. We could for example reject with the text "This proposal looks good, but in its current for it is missing X and Y. Please revise and submit a new task proposal that addresses these changes". Do you see what I mean?
Yup, that makes perfect sense! I'll get working on it ASAP.
@douwekiela When we reject the proposal, do we just send an email to the user who created the task proposal? Or should we also have that user's "Your Proposals" table show them the changes that the admin requested, and not remove the proposal from the table? This might increase the database usage though, so let me know what you think.

Resolving patch:
diff --git a/api/controllers/tasks.py b/api/controllers/tasks.py
--- a/api/controllers/tasks.py
+++ b/api/controllers/tasks.py
@@ -39,6 +39,7 @@ def process_proposal(credentials, tpid):
     data = bottle.request.json
     if not util.check_fields(data, ["accept"]):
         bottle.abort(400, "Missing data")
+
     tpm = TaskProposalModel()
     tp = tpm.get(tpid)
     tp_creator = um.get(tp.uid)
@@ -149,6 +150,20 @@ def process_proposal(credentials, tpid):
             subject="Your Task Proposal has been Accepted",
         )
 
+    else:
+        config = bottle.default_app().config
+        msg = {
+            "rejection_message": data["changes"],
+        }
+        mail.send(
+            config["mail"],
+            config,
+            [tp_creator_email],
+            template_name="templates/task_proposal_rejection.txt",
+            msg_dict=msg,
+            subject="Your Task Proposal has been Rejected",
+        )
+
     tpm.dbs.query(TaskProposal).filter(TaskProposal.id == tpid).delete()
     tpm.dbs.flush()
     tpm.dbs.commit()


Test patch: