[extensions-web] extensions: Remove single version view



commit 8038f0ef80d2bc6dd85ad9b2e07286faf93b09a8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Jun 21 18:04:33 2012 -0400

    extensions: Remove single version view
    
    It's been a half-lie ever since we added the multiversion view.
    Just don't support it anymore.

 sweettooth/extensions/models.py                    |    4 +-
 .../extensions/templates/extensions/detail.html    |   19 +--------
 .../templates/extensions/detail_edit.html          |    2 +-
 sweettooth/extensions/tests.py                     |    5 +-
 sweettooth/extensions/urls.py                      |    4 --
 sweettooth/extensions/views.py                     |   43 +-------------------
 sweettooth/review/templates/review/review.html     |    4 +-
 sweettooth/static/js/extensions.js                 |    4 --
 8 files changed, 8 insertions(+), 77 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index 796327a..5c44778 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -383,9 +383,7 @@ class ExtensionVersion(models.Model):
                 self.shell_versions.add(sv)
 
     def get_absolute_url(self):
-        return reverse('extensions-version-detail', kwargs=dict(pk=self.pk,
-                                                                ext_pk=self.extension.pk,
-                                                                slug=self.extension.slug))
+        return self.extension.get_absolute_url()
 
     def get_status_class(self):
         return STATUSES[self.status].lower()
diff --git a/sweettooth/extensions/templates/extensions/detail.html b/sweettooth/extensions/templates/extensions/detail.html
index d28f41e..0def42a 100644
--- a/sweettooth/extensions/templates/extensions/detail.html
+++ b/sweettooth/extensions/templates/extensions/detail.html
@@ -2,27 +2,10 @@
 {% load thumbnail %}
 {% block title %}{{ extension.name }} - {{ block.super }}{% endblock %}
 
-{% block extra-messages %}
-  {{ block.super }}
-  {% if is_rejected %}
-   {% spaceless %}
-    <p class="message error">
-      This version of {{ extension.name }} was rejected.
-      <a href="{{ extension.get_absolute_url }}">View the latest accepted version.</a>
-    </p>
-    {% endspaceless %}
-  {% else %} {% if old_version %}
-    <p class="message warning">
-      You are viewing an old version of <a href="{{ extension.get_absolute_url }}">{{ extension.name }}</a>
-    </p>
-  {% endif %} {% endif %}
-{% endblock %}
-
 {% block body %}
     <div class="extension single-page {% block extra-ext-class %}{% endblock %}"
          data-epk="{{ extension.pk }}"
          data-uuid="{{ extension.uuid }}"
-         data-ver-url-base="{% url extensions-version-detail ext_pk=extension.pk slug=extension.slug pk='' %}"
          data-svm="{{ shell_version_map }}">
       <div class="switch"></div>
       <div class="extra-buttons">
@@ -61,7 +44,7 @@
         </dl>
       </div>
 
-      {% if is_unreviewed %}
+      {% if not is_visible %}
       <p class="step">
         A reviewer will review the extension you submitted to make sure there's nothing too
         dangerous. You'll be emailed the result of the review.
diff --git a/sweettooth/extensions/templates/extensions/detail_edit.html b/sweettooth/extensions/templates/extensions/detail_edit.html
index 4254f3f..bd6464e 100644
--- a/sweettooth/extensions/templates/extensions/detail_edit.html
+++ b/sweettooth/extensions/templates/extensions/detail_edit.html
@@ -17,7 +17,7 @@
     <tbody>
       {% for version in all_versions %}
       <tr data-pk="{{ version.pk }}">
-        <td> <a href="{{ version.get_absolute_url }}"> {{ version.version }} </a> </td>
+        <td> {{ version.version }} </td>
         <td class="mvs">
           {% include "extensions/multiversion_status.html" %}
         </td>
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 4eb1fd9..16f3001 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -197,9 +197,8 @@ class UploadTest(BasicUserTestCase, TransactionTestCase):
         self.assertEquals(extension.description, "Simple test metadata")
         self.assertEquals(extension.url, "http://test-metadata.gnome.org";)
 
-        url = reverse('extensions-version-detail', kwargs=dict(pk=version1.pk,
-                                                               ext_pk=extension.pk,
-                                                               slug=extension.slug))
+        url = reverse('extensions-detail', kwargs=dict(pk=extension.pk,
+                                                       slug=extension.slug))
         self.assertRedirects(response, url)
 
         version1.status = models.STATUS_ACTIVE
diff --git a/sweettooth/extensions/urls.py b/sweettooth/extensions/urls.py
index bb2b675..0bb7f2d 100644
--- a/sweettooth/extensions/urls.py
+++ b/sweettooth/extensions/urls.py
@@ -33,10 +33,6 @@ urlpatterns = patterns('',
 
     url(r'^about/$', direct_to_template, dict(template='extensions/about.html'), name='extensions-about'),
 
-    # we ignore PK of extension, and get extension from version PK
-    url(r'^extension/(?P<ext_pk>\d+)/(?P<slug>.+)/version/(?P<pk>.*)/$',
-        views.extension_version_view, name='extensions-version-detail'),
-
     url(r'^extension/(?P<pk>\d+)/(?P<slug>.+)/$',
         views.extension_view, name='extensions-detail'),
     url(r'^extension/(?P<pk>\d+)/$',
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 7112b33..10ea820 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -236,46 +236,7 @@ def extension_view(request, obj, **kwargs):
     context = dict(shell_version_map = obj.visible_shell_version_map_json,
                    extension = extension,
                    all_versions = extension.versions.order_by('-version'),
-                   is_visible = True,
-                   is_multiversion = True)
-    return render(request, template_name, context)
-
- model_view(models.ExtensionVersion)
-def extension_version_view(request, obj, **kwargs):
-    extension, version = obj.extension, obj
-
-    status = version.status
-
-    # Redirect if we don't match the slug or extension PK.
-    slug = kwargs.get('slug')
-    extpk = kwargs.get('ext_pk')
-    try:
-        extpk = int(extpk)
-    except ValueError:
-        extpk = None
-
-    if slug != extension.slug or extpk != extension.pk:
-        return redirect(version)
-
-    # If the user can edit the model, let him do so.
-    if extension.user_can_edit(request.user):
-        template_name = "extensions/detail_edit.html"
-    else:
-        template_name = "extensions/detail.html"
-
-    version_obj = dict(pk = version.pk, version = version.version)
-    shell_version_map = dict((sv.version_string, version_obj) for sv in version.shell_versions.all())
-
-    context = dict(version = version,
-                   extension = extension,
-                   shell_version_map = json.dumps(shell_version_map),
-                   all_versions = extension.versions.order_by('-version'),
-                   is_unreviewed = status == models.STATUS_UNREVIEWED,
-                   is_visible = status == models.STATUS_ACTIVE,
-                   is_rejected = status == models.STATUS_REJECTED)
-
-    if extension.latest_version is not None:
-        context['old_version'] = version.version < extension.latest_version.version
+                   is_visible = extension.latest_version is not None)
     return render(request, template_name, context)
 
 @require_POST
@@ -439,7 +400,7 @@ def upload_file(request):
             version, errors = create_version(request, file_source)
             if version is not None:
                 models.submitted_for_review.send(sender=request, request=request, version=version)
-                return redirect(version)
+                return redirect(version.extension)
             else:
                 return redirect('extensions-upload-file')
     else:
diff --git a/sweettooth/review/templates/review/review.html b/sweettooth/review/templates/review/review.html
index ce9f186..938d4be 100644
--- a/sweettooth/review/templates/review/review.html
+++ b/sweettooth/review/templates/review/review.html
@@ -72,9 +72,7 @@
       {% endcomment %}
       {% for ver in all_versions %}
       <tr>
-        <td>
-          <a href="{{ ver.get_absolute_url }}">{{ ver.version }}</a>
-        </td>
+        <td> {{ ver.version }} </td>
         <td>
           {% if ver.version == version.version %}
           <span class="current_version extension-status {{ ver.get_status_class }}">{{ ver.get_status_display }}</a>
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index 18a3bca..592b612 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -12,7 +12,6 @@ function($, messages, dbusProxy, extensionUtils, templates) {
             var $table = $(this);
             var $tbody = $table.find('tbody');
             var $extension = $table.parents('.extension');
-            var urlBase = $extension.data('ver-url-base');
 
             $tbody.children().remove();
 
@@ -22,11 +21,8 @@ function($, messages, dbusProxy, extensionUtils, templates) {
                     continue;
 
                 var vpk = extensionUtils.grabProperExtensionVersion(svm, version);
-
                 var $tr = $('<tr>').appendTo($tbody);
-
                 $('<td>').append($('<code>').text(version)).appendTo($tr);
-                $('<td>').append($('<a>', {'href': urlBase + vpk.pk}).text(vpk.version)).appendTo($tr);
             }
         });
     };



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