From a482f322f032e4e51a0196c8f92a957c322dc20b Mon Sep 17 00:00:00 2001 From: Andrew Williamson Date: Tue, 4 Aug 2020 16:21:30 +0100 Subject: [PATCH] Show pending promoted addons in other reviews queue (#15167) --- src/olympia/reviewers/models.py | 7 ++++-- src/olympia/reviewers/tests/test_models.py | 5 +++- src/olympia/reviewers/tests/test_views.py | 27 +++++++++++++++++++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/olympia/reviewers/models.py b/src/olympia/reviewers/models.py index ab8ca671b2..160a1ae3ff 100644 --- a/src/olympia/reviewers/models.py +++ b/src/olympia/reviewers/models.py @@ -23,7 +23,7 @@ from olympia.amo.models import ModelBase from olympia.amo.templatetags.jinja_helpers import absolutify from olympia.amo.urlresolvers import reverse from olympia.amo.utils import cache_ns_key, send_mail -from olympia.constants.promoted import RECOMMENDED +from olympia.constants.promoted import RECOMMENDED, PRE_REVIEW_GROUPS from olympia.files.models import FileValidation from olympia.ratings.models import Rating from olympia.reviewers.sql_model import RawSQLModel @@ -243,12 +243,15 @@ class ExtensionQueueMixin: types = _int_join( set(amo.GROUP_TYPE_ADDON) - {amo.ADDON_SEARCH}) flags_table = 'addons_addonreviewerflags' + promoted_groups = _int_join( + group.id for group in PRE_REVIEW_GROUPS) query['where'].append( f'((addons.addontype_id IN ({types}) ' 'AND files.is_webextension = 0) ' f'OR {flags_table}.auto_approval_disabled = 1 ' f'OR {flags_table}.auto_approval_disabled_until_next_approval = 1 ' - f'OR {flags_table}.auto_approval_delayed_until > NOW()' + f'OR {flags_table}.auto_approval_delayed_until > NOW() ' + f'OR promoted.group_id IN ({promoted_groups})' ')' ) return query diff --git a/src/olympia/reviewers/tests/test_models.py b/src/olympia/reviewers/tests/test_models.py index b7d29ac5e1..43293ae107 100644 --- a/src/olympia/reviewers/tests/test_models.py +++ b/src/olympia/reviewers/tests/test_models.py @@ -274,8 +274,11 @@ class TestRecommendedQueue(TestQueue): addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, name='No updates') PromotedAddon.objects.get( - addon=self.new_addon(name='Not promoted')).update( + addon=self.new_addon(name='Not recommended')).update( group_id=NOT_PROMOTED.id) + PromotedAddon.objects.get( + addon=self.new_addon(name='Promoted but not recommended')).update( + group_id=LINE.id) PromotedAddon.objects.get( addon=self.new_addon(name='Not discovery item')).delete() diff --git a/src/olympia/reviewers/tests/test_views.py b/src/olympia/reviewers/tests/test_views.py index 6345fc85f4..c246f0d02a 100644 --- a/src/olympia/reviewers/tests/test_views.py +++ b/src/olympia/reviewers/tests/test_views.py @@ -40,7 +40,7 @@ from olympia.amo.tests import ( initial, reverse_ns, user_factory, version_factory) from olympia.amo.urlresolvers import reverse from olympia.blocklist.models import Block, BlocklistSubmission -from olympia.constants.promoted import RECOMMENDED +from olympia.constants.promoted import LINE, RECOMMENDED, SPOTLIGHT, STRATEGIC from olympia.constants.reviewers import ( REVIEWER_DELAYED_REJECTION_PERIOD_DAYS_DEFAULT) from olympia.constants.scanners import MAD @@ -1658,6 +1658,31 @@ class TestExtensionQueue(QueueTest): self.addons['Nominated One'], self.addons['Pending One']] self._test_results() + def test_promoted_addon_in_pre_review_group_does_show_up(self): + self.addons['Pending Two'].find_latest_version( + channel=amo.RELEASE_CHANNEL_LISTED).files.update( + is_webextension=True) + self.addons['Nominated Two'].find_latest_version( + channel=amo.RELEASE_CHANNEL_LISTED).files.update( + is_webextension=True) + self.addons['Pending One'].find_latest_version( + channel=amo.RELEASE_CHANNEL_LISTED).files.update( + is_webextension=True) + self.addons['Nominated One'].find_latest_version( + channel=amo.RELEASE_CHANNEL_LISTED).files.update( + is_webextension=True) + + self.make_addon_promoted(self.addons['Pending One'], group=LINE) + self.make_addon_promoted(self.addons['Nominated One'], group=SPOTLIGHT) + # STRATEGIC isn't a pre_review group so won't show up + self.make_addon_promoted(self.addons['Nominated Two'], group=STRATEGIC) + # RECOMMENDED is pre_review, but is handled in it's own queue + self.make_addon_promoted(self.addons['Pending Two'], group=RECOMMENDED) + + self.expected_addons = [ + self.addons['Nominated One'], self.addons['Pending One']] + self._test_results() + def test_static_theme_filtered_out(self): self.addons['Pending Two'].update(type=amo.ADDON_STATICTHEME) self.addons['Nominated Two'].update(type=amo.ADDON_STATICTHEME)