[extensions-web] Add ?version_tag=latest support in the download code



commit d1a67273e8f13eb92325963d43e57dd4bfbb1fe9
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Oct 26 11:36:10 2011 -0400

    Add ?version_tag=latest support in the download code

 sweettooth/extensions/views.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 17c5336..494dccd 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -13,10 +13,15 @@ from utils import render
 
 def download(request, uuid):
     pk = request.GET['version_tag']
-    version = get_object_or_404(models.ExtensionVersion, pk=pk)
+    if pk == 'latest':
+        extension = get_object_or_404(models.Extension, uuid=uuid)
+        version = extension.latest_version
 
-    if version.extension.uuid != uuid:
-        raise Http404()
+    else:
+        version = get_object_or_404(models.ExtensionVersion, pk=pk)
+
+        if version.extension.uuid != uuid:
+            raise Http404()
 
     if version.status != models.STATUS_ACTIVE:
         return HttpResponseForbidden()



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