From 10093120caaf8adcc7d81cf19fefcef133cf4f4c Mon Sep 17 00:00:00 2001 From: Jeff Balogh Date: Wed, 29 Sep 2010 16:51:41 -0700 Subject: [PATCH] removing unused author roles --- apps/access/acl.py | 3 +-- apps/access/tests.py | 3 +-- apps/addons/models.py | 10 +++------- apps/amo/__init__.py | 16 +++++----------- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/apps/access/acl.py b/apps/access/acl.py index 7002d8b0f0..427ac449a2 100644 --- a/apps/access/acl.py +++ b/apps/access/acl.py @@ -63,8 +63,7 @@ def check_addon_ownership(request, addon, require_owner=False): if addon.status == amo.STATUS_DISABLED: return False - roles = (amo.AUTHOR_ROLE_ADMINOWNER, amo.AUTHOR_ROLE_ADMIN, - amo.AUTHOR_ROLE_OWNER, amo.AUTHOR_ROLE_DEV) + roles = (amo.AUTHOR_ROLE_OWNER, amo.AUTHOR_ROLE_DEV) if not require_owner: roles += (amo.AUTHOR_ROLE_VIEWER,) diff --git a/apps/access/tests.py b/apps/access/tests.py index 35a053aa4d..f548f4ab58 100644 --- a/apps/access/tests.py +++ b/apps/access/tests.py @@ -110,8 +110,7 @@ class TestCheckOwnership(TestCase): def test_author_roles(self): f = self.addon.authors.filter - roles = (amo.AUTHOR_ROLE_ADMINOWNER, amo.AUTHOR_ROLE_ADMIN, - amo.AUTHOR_ROLE_OWNER, amo.AUTHOR_ROLE_DEV) + roles = (amo.AUTHOR_ROLE_OWNER, amo.AUTHOR_ROLE_DEV) check_addon_ownership(self.request, self.addon, True) eq_(f.call_args[1]['addonuser__role__in'], roles) diff --git a/apps/addons/models.py b/apps/addons/models.py index a027cc287f..49e7052f09 100644 --- a/apps/addons/models.py +++ b/apps/addons/models.py @@ -456,14 +456,12 @@ class Addon(amo.models.ModelBase): """True if ``user`` is an author with any of the specified ``roles``. ``roles`` should be a list of valid roles (see amo.AUTHOR_ROLE_*). If - not specified, then has_author will return true if the user has any - role other than amo.AUTHOR_ROLE_NONE. + not specified, has_author will return true if the user has any role. """ if user is None: return False if roles is None: - roles = amo.AUTHOR_CHOICES.keys() - roles.remove(amo.AUTHOR_ROLE_NONE) + roles = dict(amo.AUTHOR_CHOICES).keys() return AddonUser.objects.filter(addon=self, user=user, role__in=roles).exists() @@ -719,12 +717,10 @@ class AddonType(amo.models.ModelBase): class AddonUser(caching.CachingMixin, models.Model): - AUTHOR_CHOICES = amo.AUTHOR_CHOICES.items() - addon = models.ForeignKey(Addon) user = models.ForeignKey('users.UserProfile') role = models.SmallIntegerField(default=amo.AUTHOR_ROLE_OWNER, - choices=AUTHOR_CHOICES) + choices=amo.AUTHOR_CHOICES) listed = models.BooleanField(default=True) position = models.IntegerField(default=0) diff --git a/apps/amo/__init__.py b/apps/amo/__init__.py index 6201797928..16218d34f7 100644 --- a/apps/amo/__init__.py +++ b/apps/amo/__init__.py @@ -85,21 +85,15 @@ VALID_STATUSES = (STATUS_UNREVIEWED, STATUS_PENDING, STATUS_NOMINATED, STATUS_PUBLIC, STATUS_LISTED, STATUS_BETA) # Add-on author roles. -AUTHOR_ROLE_NONE = 0 AUTHOR_ROLE_VIEWER = 1 AUTHOR_ROLE_DEV = 4 AUTHOR_ROLE_OWNER = 5 -AUTHOR_ROLE_ADMIN = 6 -AUTHOR_ROLE_ADMINOWNER = 7 -AUTHOR_CHOICES = { - AUTHOR_ROLE_NONE: 'None', - AUTHOR_ROLE_VIEWER: 'Viewer', - AUTHOR_ROLE_DEV: 'Developer', - AUTHOR_ROLE_OWNER: 'Owner', - AUTHOR_ROLE_ADMIN: 'Admin', - AUTHOR_ROLE_ADMINOWNER: 'Admin & Owner', -} +AUTHOR_CHOICES = ( + (AUTHOR_ROLE_OWNER, _('Owner')), + (AUTHOR_ROLE_DEV, _('Developer')), + (AUTHOR_ROLE_VIEWER, _('Viewer')), +) # Addon types ADDON_ANY = 0