only show reviewed add-ons in other-addons-by blocks (bug 670722)
This commit is contained in:
Родитель
ee959fc3fe
Коммит
969ba69c89
|
@ -58,6 +58,10 @@ class AddonManager(amo.models.ManagerBase):
|
|||
"""Get public add-ons only"""
|
||||
return self.filter(self.valid_q([amo.STATUS_PUBLIC]))
|
||||
|
||||
def reviewed(self):
|
||||
"""Get add-ons with a reviewed status"""
|
||||
return self.filter(self.valid_q(amo.REVIEWED_STATUSES))
|
||||
|
||||
def unreviewed(self):
|
||||
"""Get only unreviewed add-ons"""
|
||||
return self.filter(self.valid_q(amo.UNREVIEWED_STATUSES))
|
||||
|
@ -69,8 +73,8 @@ class AddonManager(amo.models.ManagerBase):
|
|||
def valid_and_disabled(self):
|
||||
"""Get valid, enabled and disabled add-ons."""
|
||||
statuses = list(amo.LISTED_STATUSES) + [amo.STATUS_DISABLED]
|
||||
return self.filter(_current_version__isnull=False,
|
||||
status__in=statuses)
|
||||
return self.filter(Q(status__in=statuses) | Q(disabled_by_user=True),
|
||||
_current_version__isnull=False)
|
||||
|
||||
def featured(self, app, lang=None, type=None):
|
||||
"""
|
||||
|
|
|
@ -95,6 +95,11 @@ class TestAddonManager(amo.tests.TestCase):
|
|||
assert_not_equal(
|
||||
a.id, 3, 'public() must not return unreviewed add-ons')
|
||||
|
||||
def test_reviewed(self):
|
||||
addons = Addon.objects.reviewed()
|
||||
for a in addons:
|
||||
assert a.status in amo.REVIEWED_STATUSES, (a.id, a.status)
|
||||
|
||||
def test_unreviewed(self):
|
||||
"""
|
||||
Tests for unreviewed addons.
|
||||
|
@ -115,14 +120,16 @@ class TestAddonManager(amo.tests.TestCase):
|
|||
assert not addon.disabled_by_user
|
||||
|
||||
def test_valid_disabled_by_user(self):
|
||||
before = Addon.objects.valid_and_disabled().count()
|
||||
addon = Addon.objects.get(pk=5299)
|
||||
addon.update(disabled_by_user=True)
|
||||
eq_(Addon.objects.valid_and_disabled().count(), 10)
|
||||
eq_(Addon.objects.valid_and_disabled().count(), before)
|
||||
|
||||
def test_valid_disabled_by_admin(self):
|
||||
before = Addon.objects.valid_and_disabled().count()
|
||||
addon = Addon.objects.get(pk=5299)
|
||||
addon.update(status=amo.STATUS_DISABLED)
|
||||
eq_(Addon.objects.valid_and_disabled().count(), 10)
|
||||
eq_(Addon.objects.valid_and_disabled().count(), before)
|
||||
|
||||
|
||||
class TestAddonManagerFeatured(amo.tests.TestCase):
|
||||
|
|
|
@ -118,7 +118,7 @@ def extension_detail(request, addon):
|
|||
addon.get_satisfaction_company)
|
||||
|
||||
# Other add-ons from the same author(s).
|
||||
author_addons = (Addon.objects.valid().exclude(id=addon.id).distinct()
|
||||
author_addons = (Addon.objects.reviewed().exclude(id=addon.id).distinct()
|
||||
.filter(addonuser__listed=True,
|
||||
authors__in=addon.listed_authors))[:6]
|
||||
|
||||
|
|
|
@ -145,8 +145,8 @@ class UserProfile(amo.models.ModelBase):
|
|||
@amo.cached_property
|
||||
def addons_listed(self):
|
||||
"""Public add-ons this user is listed as author of."""
|
||||
return self.addons.valid().filter(addonuser__user=self,
|
||||
addonuser__listed=True)
|
||||
return self.addons.reviewed().filter(addonuser__user=self,
|
||||
addonuser__listed=True)
|
||||
|
||||
@property
|
||||
def picture_dir(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче