[extensions-web] Merge the "add a review" and "change status" views, merge with a combobox field



commit 89068dc9182390447e2d3e0a0553d33c475d9dd3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Oct 28 16:40:35 2011 -0400

    Merge the "add a review" and "change status" views, merge with a combobox field

 .../review/templates/review/review_reviewer.html   |   19 ++++------
 sweettooth/review/views.py                         |   38 ++++++++-----------
 2 files changed, 24 insertions(+), 33 deletions(-)
---
diff --git a/sweettooth/review/templates/review/review_reviewer.html b/sweettooth/review/templates/review/review_reviewer.html
index 5c37db2..9d63077 100644
--- a/sweettooth/review/templates/review/review_reviewer.html
+++ b/sweettooth/review/templates/review/review_reviewer.html
@@ -4,23 +4,20 @@
 {{ block.super }}
 
 <h2 class="expanded"> Review </h2>
+
 <div id="review">
   <form id="review_form" action="{% url review-submit pk=version.pk %}" method="POST">
     {% csrf_token %}
     <textarea id="comments" name="comments"></textarea>
-    <input type="submit" value="Add review">
-  </form>
-</div>
-
 {% if can_approve %}
-<div id="approve">
-  <hr>
-  <form id="approve_form" action="{% url review-approve pk=version.pk %}" method="POST">
-    {% csrf_token %}
-    <input name="newstatus" type="submit" class="approve" value="Approve">
-    <input name="newstatus" type="submit" class="reject" value="Reject">
+    <select name="status">
+      <option value="none" selected>No change</option>
+      <option value="approve">Approve</option>
+      <option value="reject">Reject</option>
+    </select>
+{% endif %}
+    <input type="submit" value="Submit">
   </form>
 </div>
-{% endif %}
 
 {% endblock %}
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index 2727976..bb56c7f 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -98,28 +98,6 @@ def ajax_get_files_view(request, obj):
 
 @post_only_view
 @model_view(models.ExtensionVersion)
-def change_status_view(request, obj):
-    if not can_approve_extension(request.user, obj.extension):
-        return HttpResponseForbidden()
-
-    newstatus_string = request.POST.get('newstatus')
-    newstatus = dict(Approve=models.STATUS_ACTIVE,
-                     Reject=models.STATUS_REJECTED)[newstatus_string]
-
-    log = ChangeStatusLog(user=request.user,
-                          version=obj,
-                          newstatus=newstatus)
-    log.save()
-
-    obj.status = newstatus
-    obj.save()
-
-    models.status_changed.send(sender=request, version=obj, log=log)
-
-    return redirect('review-list')
-
- post_only_view
- model_view(models.ExtensionVersion)
 def submit_review_view(request, obj):
     extension, version = obj.extension, obj
 
@@ -133,6 +111,22 @@ def submit_review_view(request, obj):
 
     messages.info(request, "Thank you for reviewing %s" % (extension.name,))
 
+    if can_approve_extension(request.user, obj.extension):
+        status_string = request.POST.get('status')
+        newstatus = dict(approve=models.STATUS_ACTIVE,
+                         reject=models.STATUS_REJECTED).get(status_string, None)
+
+        if newstatus is not None:
+            log = ChangeStatusLog(user=request.user,
+                                  version=obj,
+                                  newstatus=newstatus)
+            log.save()
+
+            obj.status = newstatus
+            obj.save()
+
+            models.status_changed.send(sender=request, version=obj, log=log)
+
     models.reviewed.send(sender=request, version=version, review=review)
 
     return redirect('review-list')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]