[extensions-web] extensions: Remove REJECTED_STATUSES, VISIBLE_STATUSES



commit 80a2a18b435e7c23ab9dc2a7913f52aa340f42b1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 26 02:13:58 2012 -0400

    extensions: Remove REJECTED_STATUSES, VISIBLE_STATUSES
    
    Cleaning up the status stuff means removing unused metaphors and other things.
    I don't think we'll ever need another visible status, so let's just scrap
    this.

 sweettooth/extensions/models.py |    8 +++-----
 sweettooth/extensions/views.py  |    6 +++---
 sweettooth/review/views.py      |    2 +-
 3 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index 03f3953..0892b0d 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -27,9 +27,7 @@ STATUSES = {
     STATUS_ACTIVE: u"Active",
 }
 
-VISIBLE_STATUSES = (STATUS_ACTIVE,)
 LIVE_STATUSES = (STATUS_ACTIVE, STATUS_INACTIVE)
-REJECTED_STATUSES = (STATUS_REJECTED,)
 REVIEWED_STATUSES = (STATUS_REJECTED, STATUS_INACTIVE, STATUS_ACTIVE)
 
 def validate_uuid(uuid):
@@ -45,7 +43,7 @@ def validate_uuid(uuid):
 
 class ExtensionManager(models.Manager):
     def visible(self):
-        return self.filter(versions__status__in=VISIBLE_STATUSES).distinct()
+        return self.filter(versions__status=STATUS_ACTIVE).distinct()
 
     def create_from_metadata(self, metadata, **kwargs):
         instance = self.model(**kwargs)
@@ -143,7 +141,7 @@ class Extension(models.Model):
 
     @property
     def visible_versions(self):
-        return self.versions.filter(status__in=VISIBLE_STATUSES)
+        return self.versions.filter(status=STATUS_ACTIVE)
 
     @property
     def latest_version(self):
@@ -272,7 +270,7 @@ class ExtensionVersionManager(models.Manager):
         return self.filter(status=STATUS_UNREVIEWED)
 
     def visible(self):
-        return self.filter(status__in=VISIBLE_STATUSES)
+        return self.filter(status=STATUS_ACTIVE)
 
 class ExtensionVersion(models.Model):
     extension = models.ForeignKey(Extension, related_name="versions")
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index eb3a8bd..c96ec12 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -106,7 +106,7 @@ def shell_update(request):
             operations[uuid] = dict(operation="upgrade",
                                     version_tag=proper_version.pk)
 
-        elif version_obj.status in models.REJECTED_STATUSES:
+        elif version_obj.status == models.STATUS_REJECTED:
             operations[uuid] = dict(operation="downgrade",
                                     version_tag=proper_version.pk)
 
@@ -254,8 +254,8 @@ def extension_version_view(request, obj, **kwargs):
     context = dict(version = version,
                    extension = extension,
                    shell_version_map = json.dumps(shell_version_map),
-                   is_visible = status in models.VISIBLE_STATUSES,
-                   is_rejected = status in models.REJECTED_STATUSES)
+                   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
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index 7999870..51a35ac 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -109,7 +109,7 @@ def get_latest_active_version(version):
     extension = version.extension
 
     try:
-        old_version = extension.versions.filter(version__lt=version.version, status__in=models.VISIBLE_STATUSES).latest()
+        old_version = extension.versions.filter(version__lt=version.version, status=models.STATUS_ACTIVE).latest()
     except models.ExtensionVersion.DoesNotExist:
         return None
 



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