[extensions-web] Turn the "Previous Versions" list into an "All Versions" list



commit 71ff680102bbf2b8f8629b388bee6a7358b57e42
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jan 30 14:48:39 2012 -0500

    Turn the "Previous Versions" list into an "All Versions" list
    
    With a list like:
    
      1
      2
      3
      4
      6
      7
      8
    
    It can be a little tricky to figure out that you're currently reviewing
    version 5. Let's fix this by showing and bolding the current version.

 sweettooth/review/templates/review/review.html |   26 ++++++++++++++---------
 sweettooth/review/views.py                     |   12 +++-------
 sweettooth/static/css/review.css               |   11 ++-------
 3 files changed, 23 insertions(+), 26 deletions(-)
---
diff --git a/sweettooth/review/templates/review/review.html b/sweettooth/review/templates/review/review.html
index a2bed8d..c764e44 100644
--- a/sweettooth/review/templates/review/review.html
+++ b/sweettooth/review/templates/review/review.html
@@ -44,34 +44,40 @@
       the extension zipfile</a>.</p>
 </div>
 
-{% if previous_versions %}
+{% if version.version > 1 %}
 <h2 class="expandy_header expanded"> Diff Against Previous Version </h2>
 <div id="diff" data-pk="{{ version.pk }}">
 </div>
 {% endif %}
 
-<h2 class="expandy_header expanded"> Previous Versions </h2>
-<div id="previous_versions">
-  {% if previous_versions %}
+<h2 class="expandy_header expanded"> All Versions </h2>
+<div id="all_versions">
   <table>
     <thead>
       <th>Version</th>
       <th>Status</th>
     </thead>
     <tbody>
-      {% for version in previous_versions %}
+      {% comment %}
+      This is somewhat confusing. 'ver' is the loop variable across
+      all extension versions. 'version' is the current version.
+      {% endcomment %}
+      {% for ver in all_versions %}
       <tr>
-        <td><a href="{% url extensions-version-detail ext_pk=extension.pk slug=extension.slug pk=version.pk %}">{{ version.version }}</a></td>
         <td>
-          <span class="{{ version.get_status_class }}">{{ version.get_status_display }}</span>
+          {% if ver.version == version.version %}
+          <span class="current_version">{{ ver.version }}</span>
+          {% else %}
+          <a href="{% url extensions-version-detail ext_pk=extension.pk slug=extension.slug pk=ver.pk %}">{{ ver.version }}</a>
+          {% endif %}
+        </td>
+        <td>
+          <span class="{{ ver.get_status_class }}">{{ ver.get_status_display }}</span>
         </td>
       </tr>
       {% endfor %}
     </tbody>
   </table>
-  {% else %}
-  <p>There are no previous versions of <span>{{ extension.name }}</span></p>
-  {% endif %}
 </div>
 
 {% if previous_reviews %}
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index 05c9d31..a5467ca 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -266,21 +266,17 @@ def submit_review_view(request, obj):
 def review_version_view(request, obj):
     extension, version = obj.extension, obj
 
-    # Reviews on previous versions of the same extension.
-    previous_versions = extension.versions.order_by('-version')
+    # Reviews on all versions of the same extension.
+    all_versions = extension.versions.order_by('-version')
 
-    # Exclude this version...
-    previous_versions = previous_versions.exclude(version=version.version)
-
-
-    # Other reviews on the same version
+    # Other reviews on the same version.
     previous_reviews = version.reviews.all()
 
     can_approve = can_approve_extension(request.user, extension)
 
     context = dict(extension=extension,
                    version=version,
-                   previous_versions=previous_versions,
+                   all_versions=all_versions,
                    previous_reviews=previous_reviews,
                    can_approve=can_approve)
 
diff --git a/sweettooth/static/css/review.css b/sweettooth/static/css/review.css
index c79eb83..251f9ca 100644
--- a/sweettooth/static/css/review.css
+++ b/sweettooth/static/css/review.css
@@ -129,23 +129,18 @@ span.changed {
     margin-bottom: 20px;
 }
 
-#previous_versions table {
+#all_versions table {
     width: 100%;
 }
 
-#previous_versions td {
+#all_versions td {
     text-align: center;
 }
 
-#previous_versions p span {
+#all_versions .current_version {
     font-weight: bold;
 }
 
-#previous_versions p {
-    text-align: center;
-    font-size: larger;
-}
-
 #approve {
     clear: right;
 }



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