[extensions-web] extensions: Take the current shell version into account



commit 2b7ff8662e05205a965ba446c43156306c23aa0c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Apr 24 04:05:27 2012 -0400

    extensions: Take the current shell version into account

 sweettooth/extensions/tests.py |    2 +-
 sweettooth/extensions/views.py |   11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 2e3f60e..73b4039 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -479,7 +479,7 @@ class UpdateVersionTest(TestCase):
 
     def grab_response(self, installed):
         response = self.client.get(reverse('extensions-shell-update'),
-                                   dict(installed=json.dumps(installed)))
+                                   dict(installed=json.dumps(installed), shell_version='3.2.0'))
 
         return json.loads(response.content)
 
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 3ee69cc..195651a 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -83,6 +83,7 @@ def shell_download(request, uuid):
 @ajax_view
 def shell_update(request):
     installed = json.loads(request.GET['installed'])
+    shell_version = request.GET['shell_version']
     operations = {}
 
     for uuid, version in installed.iteritems():
@@ -97,18 +98,18 @@ def shell_update(request):
             # The user may have a newer version than what's on the site.
             continue
 
-        latest_version = extension.latest_version
+        proper_version = grab_proper_extension_version(extension, shell_version)
 
-        if latest_version is None:
+        if proper_version is None:
             operations[uuid] = dict(operation="blacklist")
 
-        elif version < latest_version.version:
+        elif version < proper_version.version:
             operations[uuid] = dict(operation="upgrade",
-                                    version_tag=extension.latest_version.pk)
+                                    version_tag=proper_version.pk)
 
         elif version_obj.status in models.REJECTED_STATUSES:
             operations[uuid] = dict(operation="downgrade",
-                                    version_tag=extension.latest_version.pk)
+                                    version_tag=proper_version.pk)
 
     return operations
 



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