removing unused author roles
This commit is contained in:
Родитель
2fdcec1ceb
Коммит
10093120ca
|
@ -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,)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче