Skip to content

Commit 7683eea

Browse files
committed
rename promoted_group, promoted
1 parent e1370cc commit 7683eea

File tree

31 files changed

+153
-153
lines changed

31 files changed

+153
-153
lines changed

src/olympia/abuse/actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def should_hold_action(self):
256256
or self.target.groups_list # has any permissions
257257
# owns a high profile add-on
258258
or any(
259-
any(addon.promoted_group(currently_approved=False).high_profile)
259+
any(addon.promoted_groups(currently_approved=False).high_profile)
260260
for addon in self.target.addons.all()
261261
)
262262
)
@@ -287,7 +287,7 @@ def should_hold_action(self):
287287
return bool(
288288
self.target.status != amo.STATUS_DISABLED
289289
# is a high profile add-on
290-
and any(self.target.promoted_group(currently_approved=False).high_profile)
290+
and any(self.target.promoted_groups(currently_approved=False).high_profile)
291291
)
292292

293293
def log_action(self, activity_log_action, *extra_args, extra_details=None):
@@ -518,7 +518,7 @@ def should_hold_action(self):
518518
not self.target.deleted
519519
and self.target.reply_to
520520
and any(
521-
self.target.addon.promoted_group(
521+
self.target.addon.promoted_groups(
522522
currently_approved=False
523523
).high_profile_rating
524524
)

src/olympia/abuse/cinder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def get_attributes(self):
351351
# promoted in any way, but we don't care about the promotion being
352352
# approved for the current version, it would make more queries and it's
353353
# not useful for moderation purposes anyway.
354-
promoted_group = self.addon.promoted_group(currently_approved=False)
354+
promoted_group = self.addon.promoted_groups(currently_approved=False)
355355
data = {
356356
'id': self.id,
357357
'average_daily_users': self.addon.average_daily_users,

src/olympia/addons/indexers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def extract_document(cls, obj):
664664

665665
data['is_recommended'] = any(
666666
PROMOTED_GROUP_CHOICES.RECOMMENDED == promotion.group_id
667-
for promotion in obj.promoted
667+
for promotion in obj.cached_promoted_groups
668668
)
669669

670670
data['previews'] = [
@@ -685,7 +685,7 @@ def extract_document(cls, obj):
685685
app.id for app in obj.approved_applications_for(promotion)
686686
],
687687
}
688-
for promotion in obj.promoted
688+
for promotion in obj.cached_promoted_groups
689689
)
690690

691691
data['ratings'] = {

src/olympia/addons/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ def _is_recommended_theme(self):
15561556
).exists()
15571557
)
15581558

1559-
def promoted_group(self, *, currently_approved=True):
1559+
def promoted_groups(self, *, currently_approved=True):
15601560
"""Is the addon currently promoted for the current applications?
15611561
15621562
Returns the group constant, or NOT_PROMOTED (which is falsey)
@@ -1576,8 +1576,8 @@ def promoted_group(self, *, currently_approved=True):
15761576
)
15771577

15781578
@cached_property
1579-
def promoted(self):
1580-
promoted_group = self.promoted_group()
1579+
def cached_promoted_groups(self):
1580+
promoted_group = self.promoted_groups()
15811581
if promoted_group:
15821582
return promoted_group.all()
15831583
else:
@@ -1658,7 +1658,7 @@ def can_set_compatibility(self):
16581658
def can_be_compatible_with_all_fenix_versions(self):
16591659
"""Whether or not the addon is allowed to be compatible with all Fenix
16601660
versions (i.e. it's a recommended/line extension for Android)."""
1661-
promotions = self.promoted
1661+
promotions = self.cached_promoted_groups
16621662
approved_applications = self.approved_applications
16631663

16641664
return (

src/olympia/addons/serializers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def validate_is_disabled(self, disable):
513513
):
514514
raise exceptions.ValidationError(gettext('File is already disabled.'))
515515
if not version.can_be_disabled_and_deleted():
516-
group = version.addon.promoted_group()
516+
group = version.addon.promoted_groups()
517517
msg = gettext(
518518
'The latest approved version of this %s add-on cannot be deleted '
519519
'because the previous version was not approved for %s promotion. '
@@ -1026,7 +1026,7 @@ class AddonSerializer(AMOModelSerializer):
10261026
],
10271027
)
10281028
previews = PreviewSerializer(many=True, source='current_previews', read_only=True)
1029-
promoted = serializers.SerializerMethodField()
1029+
promoted = serializers.SerializerMethodField(source='cached_promoted_groups')
10301030
ratings = serializers.SerializerMethodField()
10311031
ratings_url = serializers.SerializerMethodField()
10321032
review_url = serializers.SerializerMethodField()
@@ -1148,7 +1148,7 @@ def to_representation(self, obj):
11481148
return data
11491149

11501150
def get_promoted(self, obj):
1151-
promoted = obj.promoted
1151+
promoted = obj.cached_promoted_groups
11521152
return PromotedGroupSerializer(
11531153
many=True, read_only=True, instance=promoted, addon=obj
11541154
).data
@@ -1163,7 +1163,7 @@ def is_recommended(obj):
11631163
try:
11641164
return any(
11651165
PROMOTED_GROUP_CHOICES.RECOMMENDED == promotion.group_id
1166-
for promotion in obj.promoted
1166+
for promotion in obj.cached_promoted_groups
11671167
)
11681168
except TypeError:
11691169
return PROMOTED_GROUP_CHOICES.RECOMMENDED == obj.promoted.group_id

src/olympia/addons/tests/test_models.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,88 +1635,88 @@ def test_attach_previews(self):
16351635
vp = VersionPreview.objects.create(version=addons[3].current_version)
16361636
assert addons[3].current_previews == [vp]
16371637

1638-
def test_promoted_group(self):
1638+
def test_promoted_groups(self):
16391639
addon = addon_factory()
16401640
# default case - no group so not recommended
1641-
assert not addon.promoted_group()
1642-
assert not addon.promoted_group(currently_approved=False)
1641+
assert not addon.promoted_groups()
1642+
assert not addon.promoted_groups(currently_approved=False)
16431643

16441644
# It's promoted but nothing has been approved
16451645
promoted = PromotedAddon.objects.create(
16461646
addon=addon, group_id=PROMOTED_GROUP_CHOICES.LINE
16471647
)
1648-
assert addon.promoted_group(currently_approved=False)
1649-
assert not addon.promoted_group()
1648+
assert addon.promoted_groups(currently_approved=False)
1649+
assert not addon.promoted_groups()
16501650

16511651
# The latest version is approved for the same group.
16521652
promoted.approve_for_version(version=addon.current_version)
1653-
assert addon.promoted_group()
1654-
assert PROMOTED_GROUP_CHOICES.LINE in addon.promoted_group().group_id
1653+
assert addon.promoted_groups()
1654+
assert PROMOTED_GROUP_CHOICES.LINE in addon.promoted_groups().group_id
16551655

16561656
# if the group has changes the approval for the current version isn't
16571657
# valid
16581658
promoted.update(group_id=PROMOTED_GROUP_CHOICES.SPOTLIGHT)
1659-
assert not addon.promoted_group()
1660-
assert addon.promoted_group(currently_approved=False)
1659+
assert not addon.promoted_groups()
1660+
assert addon.promoted_groups(currently_approved=False)
16611661
assert (
16621662
PROMOTED_GROUP_CHOICES.SPOTLIGHT
1663-
in addon.promoted_group(currently_approved=False).group_id
1663+
in addon.promoted_groups(currently_approved=False).group_id
16641664
)
16651665

16661666
promoted.approve_for_version(version=addon.current_version)
1667-
assert PROMOTED_GROUP_CHOICES.SPOTLIGHT in addon.promoted_group().group_id
1667+
assert PROMOTED_GROUP_CHOICES.SPOTLIGHT in addon.promoted_groups().group_id
16681668

16691669
# Application specific group membership should work too
16701670
# if no app is specifed in the PromotedAddon everything should match
1671-
assert PROMOTED_GROUP_CHOICES.SPOTLIGHT in addon.promoted_group().group_id
1671+
assert PROMOTED_GROUP_CHOICES.SPOTLIGHT in addon.promoted_groups().group_id
16721672

16731673
# update to mobile app
16741674
promoted.update(application_id=amo.ANDROID.id)
1675-
assert addon.promoted_group()
1675+
assert addon.promoted_groups()
16761676
# but if there's no approval for Android it's not promoted
16771677
addon.current_version.promoted_approvals.filter(
16781678
application_id=amo.ANDROID.id
16791679
).delete()
1680-
assert not addon.promoted_group()
1680+
assert not addon.promoted_groups()
16811681
promoted.update(application_id=amo.FIREFOX.id)
1682-
assert PROMOTED_GROUP_CHOICES.SPOTLIGHT in addon.promoted_group().group_id
1682+
assert PROMOTED_GROUP_CHOICES.SPOTLIGHT in addon.promoted_groups().group_id
16831683

16841684
# check it doesn't error if there's no current_version
16851685
addon.current_version.file.update(status=amo.STATUS_DISABLED)
16861686
addon.update_version()
16871687
assert not addon.current_version
1688-
assert not addon.promoted_group()
1689-
assert addon.promoted_group(currently_approved=False)
1688+
assert not addon.promoted_groups()
1689+
assert addon.promoted_groups(currently_approved=False)
16901690

16911691
def test_promoted(self):
16921692
addon = addon_factory()
16931693
# default case - no group so return None.
1694-
assert not addon.promoted
1694+
assert not addon.cached_promoted_groups
16951695

16961696
# It's promoted but nothing has been approved.
16971697
promoted = PromotedAddon.objects.create(
16981698
addon=addon, group_id=PROMOTED_GROUP_CHOICES.LINE
16991699
)
1700-
assert not addon.promoted
1700+
assert not addon.cached_promoted_groups
17011701

17021702
# The latest version is approved.
17031703
promoted.approve_for_version(addon.current_version)
1704-
del addon.promoted
1704+
del addon.cached_promoted_groups
17051705
assert any(
1706-
promotion.group_id == promoted.group_id for promotion in addon.promoted
1706+
promotion.group_id == promoted.group_id for promotion in addon.cached_promoted_groups
17071707
)
17081708

17091709
# If the group changes the approval for the current version isn't
17101710
# valid.
17111711
promoted.update(group_id=PROMOTED_GROUP_CHOICES.SPOTLIGHT)
1712-
del addon.promoted
1713-
assert not addon.promoted
1712+
del addon.cached_promoted_groups
1713+
assert not addon.cached_promoted_groups
17141714

17151715
# Add an approval for the new group.
17161716
promoted.approve_for_version(addon.current_version)
1717-
del addon.promoted
1717+
del addon.cached_promoted_groups
17181718
assert any(
1719-
promotion.group_id == promoted.group_id for promotion in addon.promoted
1719+
promotion.group_id == promoted.group_id for promotion in addon.cached_promoted_groups
17201720
)
17211721

17221722
def test_promoted_theme(self):
@@ -1725,23 +1725,23 @@ def test_promoted_theme(self):
17251725
)
17261726
addon = addon_factory(type=amo.ADDON_STATICTHEME)
17271727
# default case - no group so return None.
1728-
assert not addon.promoted
1728+
assert not addon.cached_promoted_groups
17291729

17301730
featured_collection, _ = Collection.objects.get_or_create(
17311731
id=settings.COLLECTION_FEATURED_THEMES_ID
17321732
)
17331733
featured_collection.add_addon(addon)
1734-
del addon.promoted
1734+
del addon.cached_promoted_groups
17351735
# it's in the collection, so is now promoted.
1736-
assert addon.promoted
1736+
assert addon.cached_promoted_groups
17371737
assert any(recommended == promotion for promotion in addon.promoted)
17381738

17391739
featured_collection.remove_addon(addon)
1740-
del addon.promoted
1740+
del addon.cached_promoted_groups
17411741
addon = Addon.objects.get(id=addon.id)
17421742
# assert not addon.promotedaddon
17431743
# but not when it's removed.
1744-
assert not addon.promoted
1744+
assert not addon.cached_promoted_groups
17451745

17461746
def test_block_property(self):
17471747
addon = Addon.objects.get(id=3615)
@@ -1789,7 +1789,7 @@ def test_can_be_compatible_with_all_fenix_versions_property(self):
17891789

17901790
# The latest version is approved.
17911791
promoted.approve_for_version(addon.current_version)
1792-
del addon.promoted
1792+
del addon.cached_promoted_groups
17931793
assert addon.can_be_compatible_with_all_fenix_versions
17941794

17951795
promoted.update(application_id=amo.FIREFOX.id)

src/olympia/addons/tests/test_serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def test_promoted_shim(self):
586586
promoted_group=group,
587587
)
588588

589-
assert self.addon.promoted_group()
589+
assert self.addon.promoted_groups()
590590

591591
# v3 and v4 expect the promoted addon directly.
592592
gates = {self.request.version: ('promoted-groups-shim',)}

src/olympia/addons/tests/test_views.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5622,7 +5622,7 @@ def test_filter_by_featured_no_app_no_lang(self):
56225622
promoted_id=PROMOTED_GROUP_CHOICES.RECOMMENDED,
56235623
)
56245624
addon_factory(slug='other-addon', name='Other Addôn')
5625-
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon.promoted_group().group_id
5625+
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon.promoted_groups().group_id
56265626
self.reindex(Addon)
56275627

56285628
data = self.perform_search(self.url, {'featured': 'true'})
@@ -5647,7 +5647,7 @@ def test_filter_by_promoted(self):
56475647
min=av_min,
56485648
max=av_max,
56495649
)
5650-
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon.promoted_group().group_id
5650+
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon.promoted_groups().group_id
56515651
assert addon.promotedaddon.application_id is None # i.e. all
56525652
assert addon.approved_applications == [
56535653
amo.FIREFOX,
@@ -5665,7 +5665,7 @@ def test_filter_by_promoted(self):
56655665
)
56665666
# This case is approved for all apps, but now only set for Firefox
56675667
addon2.promotedaddon.update(application_id=amo.FIREFOX.id)
5668-
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon2.promoted_group().group_id
5668+
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon2.promoted_groups().group_id
56695669
assert addon2.promotedaddon.application_id is amo.FIREFOX.id
56705670
assert addon2.approved_applications == [amo.FIREFOX]
56715671

@@ -5690,7 +5690,7 @@ def test_filter_by_promoted(self):
56905690
addon4.promotedaddon.update(application_id=amo.FIREFOX.id)
56915691
addon4.promotedaddon.approve_for_version(addon4.current_version)
56925692
addon4.promotedaddon.update(application_id=None)
5693-
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon4.promoted_group().group_id
5693+
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon4.promoted_groups().group_id
56945694
assert addon4.promotedaddon.application_id is None # i.e. all
56955695
assert addon4.approved_applications == [amo.FIREFOX]
56965696

@@ -5706,7 +5706,7 @@ def test_filter_by_promoted(self):
57065706
addon5.promotedaddon.update(application_id=amo.ANDROID.id)
57075707
addon5.promotedaddon.approve_for_version(addon5.current_version)
57085708
addon5.promotedaddon.update(application_id=None)
5709-
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon5.promoted_group().group_id
5709+
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon5.promoted_groups().group_id
57105710
assert addon5.promotedaddon.application_id is None # i.e. all
57115711
assert addon5.approved_applications == [amo.ANDROID]
57125712

@@ -6645,8 +6645,8 @@ def tearDown(self):
66456645
def test_basic(self):
66466646
addon1 = addon_factory(promoted_id=PROMOTED_GROUP_CHOICES.RECOMMENDED)
66476647
addon2 = addon_factory(promoted_id=PROMOTED_GROUP_CHOICES.RECOMMENDED)
6648-
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon1.promoted_group().group_id
6649-
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon2.promoted_group().group_id
6648+
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon1.promoted_groups().group_id
6649+
assert PROMOTED_GROUP_CHOICES.RECOMMENDED in addon2.promoted_groups().group_id
66506650
addon_factory() # not recommended so shouldn't show up
66516651
self.refresh()
66526652

src/olympia/addons/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ def update(self, request, *args, **kwargs):
732732
def destroy(self, request, *args, **kwargs):
733733
instance = self.get_object()
734734
if not instance.can_be_disabled_and_deleted():
735-
group = self.get_addon_object().promoted_group()
735+
group = self.get_addon_object().promoted_groups()
736736
msg = gettext(
737737
'The latest approved version of this %s add-on cannot be deleted '
738738
'because the previous version was not approved for %s promotion. '

src/olympia/devhub/templates/devhub/includes/addon_details.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% set status_text = _('Invisible') %}
77
{% set tooltip_text = status_tips['invisible'] %}
88
{% else %}
9-
{% set promoted_group = addon.promoted_group() %}
9+
{% set promoted_group = addon.promoted_groups() %}
1010
{% if addon.status == amo.STATUS_APPROVED and promoted_group.badged|python_any %}
1111
{% set status_text = _('Approved and %s' % promoted_group.name) %}
1212
{% else %}

src/olympia/devhub/templates/devhub/new-landing/components/my-addons.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% macro render_status(addon) %}
2-
{% set promoted_group = addon.promoted_group() %}
2+
{% set promoted_group = addon.promoted_groups() %}
33
{% if addon.status != amo.STATUS_DISABLED and addon.disabled_by_user %}
44
{% set status_text = _('Invisible') %}
55
{% elif addon.status == amo.STATUS_APPROVED and promoted_group.badged|python_any %}

src/olympia/devhub/templates/devhub/versions/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ <h3 data-tmpl="{{ _('Delete Version {version}') }}"></h3>
297297
</form>
298298
<p class="promoted-version-warning">
299299
{# will be hidden by default, shown by javascript if data-can-be-disabled is falsey #}
300-
{% trans promoted_group_name = addon.promoted_group().name %}
300+
{% trans promoted_group_name = addon.promoted_groups().name %}
301301
The latest approved version of this {{ promoted_group_name }} add-on cannot be deleted or disabled
302302
because the previous version was not approved for {{ promoted_group_name }} promotion.
303303
Please contact AMO Admins if you need help with this.

src/olympia/devhub/tests/test_views_submit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2493,7 +2493,7 @@ def test_submit_notification_warning(self):
24932493
assert doc('.notification-box.warning')
24942494
assert doc('.notification-box.warning').html().strip() == config.value
24952495

2496-
def test_submit_notification_warning_pre_review_ignore_if_not_promoted_group(self):
2496+
def test_submit_notification_warning_pre_review_ignore_if_not_promoted_groups(self):
24972497
Config.objects.create(
24982498
key='submit_notification_warning_pre_review',
24992499
value='Warning for pre_review and <a href="http://example.com">a link</a>.',

src/olympia/devhub/tests/test_views_versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def test_can_disable_or_delete_current_ver_if_previous_recommended(self):
243243
assert self.addon.current_version == previous_version
244244
# It's still recommended.
245245
assert (
246-
PROMOTED_GROUP_CHOICES.RECOMMENDED in self.addon.promoted_group().group_id
246+
PROMOTED_GROUP_CHOICES.RECOMMENDED in self.addon.promoted_groups().group_id
247247
)
248248

249249
def test_can_still_disable_or_delete_old_version_recommended(self):

0 commit comments

Comments
 (0)