Make "Mark as Ineligible" reversable and make this feature available for mentors too.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Mon, 06 Apr 2009 10:11:44 +0000
changeset 2091 dd3eb2770205
parent 2090 a07ff1e1bd1f
child 2092 6de3693ba9d4
Make "Mark as Ineligible" reversable and make this feature available for mentors too. Now also with every click on "Mark as Ineligible" or "Mark as Eligible" button a private comment is posted with message "Marked Student Proposal as Ineligible/Eligible" which will help keep track of the changes made by mentors/org admins. Patch by: Pawel Solyga Reviewed by: to-be-reviewed
app/soc/templates/soc/student_proposal/review.html
app/soc/views/models/student_proposal.py
--- a/app/soc/templates/soc/student_proposal/review.html	Sun Apr 05 23:39:36 2009 +0000
+++ b/app/soc/templates/soc/student_proposal/review.html	Mon Apr 06 10:11:44 2009 +0000
@@ -123,11 +123,18 @@
      </td>
      {% endif %}
    {% endif %}
-   {% if is_org_admin %}
+   {% if is_org_admin or is_mentor %}
+     {% ifequal entity.status "invalid" %}
+     <td>
+       <input style="font-weight: bold" type="button" value="Mark as Eligible"
+       onclick="if (confirm('Are you sure you want to mark this proposal as eligible?')) { location.href='?ineligible=0'; }"/>
+     </td>
+     {% else %}
      <td>
        <input style="font-weight: bold" type="button" value="Mark as Ineligible"
-       onclick="if (confirm('Are you sure? This can not be undone!')) { location.href='?ineligible=1'; }"/>
+       onclick="if (confirm('Are you sure you want to mark this proposal as ineligible?')) { location.href='?ineligible=1'; }"/>
      </td>
+     {% endifequal %}
    {% endif %}
    </tr>
  </table>
--- a/app/soc/views/models/student_proposal.py	Sun Apr 05 23:39:36 2009 +0000
+++ b/app/soc/views/models/student_proposal.py	Mon Apr 06 10:11:44 2009 +0000
@@ -711,15 +711,35 @@
     if mentor and choice:
       self._adjustPossibleMentors(entity, mentor, choice)
 
-    is_ineligible = get_dict.get('ineligible')
-    if org_admin and is_ineligible:
-      # mark the proposal invalid and return to the list
-      properties = {'status': 'invalid'}
-      self._logic.updateEntityProperties(entity, properties)
+    ineligible = get_dict.get('ineligible')
+    
+    if org_admin:
+      reviewer = org_admin
+    elif mentor:
+      reviewer = mentor
+    
+    if (org_admin or mentor) and ineligible != None:
+      ineligible = int(ineligible)
+      if ineligible == 1:
+        # mark the proposal invalid and return to the list
+        properties = {'status': 'invalid'}
+        self._logic.updateEntityProperties(entity, properties)
 
-      redirect = redirects.getListProposalsRedirect(entity.org,
-                                                    {'url_name': 'org'})
-      return http.HttpResponseRedirect(redirect)
+        redirect = redirects.getListProposalsRedirect(entity.org,
+                                                      {'url_name': 'org'})
+        comment = "Marked Student Proposal as Ineligible."
+        self._createReviewFor(entity, reviewer, comment, is_public=False)
+        return http.HttpResponseRedirect(redirect)
+      elif ineligible == 0:
+        # mark the proposal as new and return to the list
+        properties = {'status': 'new'}
+        self._logic.updateEntityProperties(entity, properties)
+
+        redirect = redirects.getListProposalsRedirect(entity.org,
+                                                      {'url_name': 'org'})
+        comment = "Marked Student Proposal as Eligible."
+        self._createReviewFor(entity, reviewer, comment, is_public=False)
+        return http.HttpResponseRedirect(redirect)
 
     # check if we should change the subscription state for the current user
     public_subscription = None
@@ -862,6 +882,7 @@
 
     # which button should we show to the mentor?
     if mentor:
+      context['is_mentor'] = True
       if mentor.key() in possible_mentors:
         # show "No longer willing to mentor"
         context['remove_me_as_mentor'] = True