Skip to content

Only Show Badged Promoted Groups in Devhub #23372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/olympia/abuse/cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def get_attributes(self):
# promoted in any way, but we don't care about the promotion being
# approved for the current version, it would make more queries and it's
# not useful for moderation purposes anyway.
promoted_group = self.addon.promoted_groups(currently_approved=False)
promoted_groups = self.addon.promoted_groups(currently_approved=False)
data = {
'id': self.id,
'average_daily_users': self.addon.average_daily_users,
Expand All @@ -353,7 +353,7 @@ def get_attributes(self):
'name': self.get_str(self.addon.name),
'slug': self.addon.slug,
'summary': self.get_str(self.addon.summary),
'promoted': self.get_str(promoted_group.name),
'promoted': self.get_str(promoted_groups.name),
}
return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
{% set status_text = _('Invisible') %}
{% set tooltip_text = status_tips['invisible'] %}
{% else %}
{% set promoted_group = addon.promoted_groups() %}
{% if addon.status == amo.STATUS_APPROVED and promoted_group.badged|python_any %}
{% set status_text = _('Approved and %s' % promoted_group.name) %}
{% set promoted_groups = addon.promoted_groups() %}
{% if addon.status == amo.STATUS_APPROVED and promoted_groups.badged|python_any %}
{% set status_text = _('Approved and %s' % promoted_groups.filter(badged=True).name) %}
{% else %}
{% set status_text = addon.get_status_display() %}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% macro render_status(addon) %}
{% set promoted_group = addon.promoted_groups() %}
{% set promoted_groups = addon.promoted_groups() %}
{% if addon.status != amo.STATUS_DISABLED and addon.disabled_by_user %}
{% set status_text = _('Invisible') %}
{% elif addon.status == amo.STATUS_APPROVED and promoted_group.badged|python_any %}
{% set status_text = _('Approved and %s' % promoted_group.name) %}
{% elif addon.status == amo.STATUS_APPROVED and promoted_groups.badged|python_any %}
{% set status_text = _('Approved and %s' % promoted_groups.name) %}
{% else %}
{% set status_text = addon.get_status_display() %}
{% endif %}
Expand Down
22 changes: 22 additions & 0 deletions src/olympia/devhub/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,28 @@ def test_disabled_post_admin(self):
assert 'no-edit' not in doc('body')[0].attrib['class']
self.assert3xx(self.client.post(self.delete_url), self.get_url)

def test_dev_promoted_status(self):
self.make_addon_promoted(
addon=self.addon, group_id=PROMOTED_GROUP_CHOICES.RECOMMENDED
)
self.make_addon_promoted(addon=self.addon, group_id=PROMOTED_GROUP_CHOICES.LINE)
self.make_addon_promoted(
addon=self.addon, group_id=PROMOTED_GROUP_CHOICES.SPOTLIGHT
)
self.addon.approve_for_version()
assert (
PROMOTED_GROUP_CHOICES.RECOMMENDED in self.addon.promoted_groups().group_id
)
assert PROMOTED_GROUP_CHOICES.LINE in self.addon.promoted_groups().group_id
assert PROMOTED_GROUP_CHOICES.SPOTLIGHT in self.addon.promoted_groups().group_id

response = self.client.get(self.get_url)
assert response.status_code == 200
doc = pq(response.content)
assert 'Recommended' in doc('.addon-listed-status').text()
assert 'By Firefox' in doc('.addon-listed-status').text()
assert 'Spotlight' not in doc('.addon-listed-status').text()


class TestVersionStats(TestCase):
fixtures = ['base/users', 'base/addon_3615']
Expand Down
16 changes: 8 additions & 8 deletions src/olympia/reviewers/templates/reviewers/review.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ <h4 class="author">by

</hgroup>

{% if promoted_group %}
{% if promoted_groups %}
{# Technically could be just pending approval, but that doesn't matter for this message. #}
<p class="is_promoted">
This is a {{ promoted_group.name }} add-on.
{% if (amo.promoted.PROMOTED_GROUP_CHOICES.RECOMMENDED in promoted_group.group_id and not action_allowed_for(request.user, amo.permissions.ADDONS_RECOMMENDED_REVIEW)) or
(promoted_group.admin_review|python_any and not action_allowed_for(request.user, amo.permissions.REVIEWS_ADMIN)) %}
This is a {{ promoted_groups.name }} add-on.
{% if (amo.promoted.PROMOTED_GROUP_CHOICES.RECOMMENDED in promoted_groups.group_id and not action_allowed_for(request.user, amo.permissions.ADDONS_RECOMMENDED_REVIEW)) or
(promoted_groups.admin_review|python_any and not action_allowed_for(request.user, amo.permissions.REVIEWS_ADMIN)) %}
You don't have permission to review it.
{% endif %}
</p>
Expand Down Expand Up @@ -131,12 +131,12 @@ <h3 id="history">
</div>
</div>

{% if promoted_group %}
{% if promoted_groups %}
{# Technically could be just pending approval, but that doesn't matter for this message. #}
<p class="is_promoted">
This is a {{ promoted_group.name }} add-on.
{% if (amo.promoted.PROMOTED_GROUP_CHOICES.RECOMMENDED in promoted_group.group_id and not action_allowed_for(request.user, amo.permissions.ADDONS_RECOMMENDED_REVIEW)) or
(promoted_group.admin_review|python_any and not action_allowed_for(request.user, amo.permissions.REVIEWS_ADMIN)) %}
This is a {{ promoted_groups.name }} add-on.
{% if (amo.promoted.PROMOTED_GROUP_CHOICES.RECOMMENDED in promoted_groups.group_id and not action_allowed_for(request.user, amo.permissions.ADDONS_RECOMMENDED_REVIEW)) or
(promoted_groups.admin_review|python_any and not action_allowed_for(request.user, amo.permissions.REVIEWS_ADMIN)) %}
You don't have permission to review it.
{% endif %}
</p>
Expand Down
4 changes: 2 additions & 2 deletions src/olympia/reviewers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def review(request, addon, channel=None):
channel, content_review = determine_channel(channel)

is_static_theme = addon.type == amo.ADDON_STATICTHEME
promoted_group = addon.promoted_groups(currently_approved=False)
promoted_groups = addon.promoted_groups(currently_approved=False)

# Are we looking at an unlisted review page, or (weirdly) the listed
# review page of an unlisted-only add-on?
Expand Down Expand Up @@ -764,7 +764,7 @@ def review(request, addon, channel=None):
and version.is_unreviewed
and not version.pending_rejection
),
promoted_group=promoted_group,
promoted_groups=promoted_groups,
name_translations=name_translations,
now=datetime.now(),
num_pages=num_pages,
Expand Down