Skip to content

Show matched restriction instances on review page - #25423

Open
jasonBirchall wants to merge 1 commit into
masterfrom
reviewer-restriction-links
Open

Show matched restriction instances on review page#25423
jasonBirchall wants to merge 1 commit into
masterfrom
reviewer-restriction-links

Conversation

@jasonBirchall

Copy link
Copy Markdown
Contributor

Fixes mozilla/addons#16408

Description

What this change does:

  • The DISABLE_AUTO_APPROVAL entry in the review page's important-changes history now lists the specific restriction instance(s) that matched, resolved from the UserRestrictionHistory rows recorded at submission time (via the restriction_history_ids the entry already carries).
  • Each match shows class and value ("EmailUserRestriction: foo@example.com"), linked to its admin change page for users with Admin:Advanced, plain text for everyone else.
  • A match whose restriction has since been deleted shows "restriction since removed"; a structural denial with no instance shows "no specific restriction matched".

What it looks like:

The entry in "Add-on important changes history" gains a list under the existing comment, one line per matched restriction.

A reviewer with Admin:Advanced sees each value as a link to that
restriction's admin page:

Listed auto-approval automatically disabled because of a restriction (EmailUserRestriction, IPNetworkUserRestriction)

  • EmailUserRestriction: foo@example.com <- links to /admin/models/users/emailuserrestriction/1257/change/
  • IPNetworkUserRestriction: 10.0.0.0/24 <- links to /admin/models/users/ipnetworkuserrestriction/527/change/

Why this shape:

  1. Rendered from the recorded history rows, never AddonReviewerFlags. The flag is add-on-level and has non-restriction causes (Mozilla-signed packages), so it can't say which restriction fired.
  2. The link is gated on Admin:Advanced because that's the
    exact permission gating the restriction admin pages. Nobody gets a link they can't follow, and reviewers without it still see the value.
  3. "Since removed" is a designed state, not an error: restrictions are bulk-deleted or are normal for an audit trail.
  4. The restriction's reason field is deliberately not shown. It's documented as a private description.

Context

Completes the third acceptance criterion of #16408 (the DB and Redash queryability landed in #25344; this is the reviewer-facing exposure agreed as a follow-up).

Testing

Six tests in TestReview: the admin link href and value for an Admin:Advanced user; value-without-link for a regular reviewer; two
matched restrictions rendering two links; a deleted restriction
rendering "since removed" with no link; a structural NULL-instance row rendering its message; and the existing comment-rendering test unchanged. Full reviewers/tests/test_views.py passes.

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).

The DISABLE_AUTO_APPROVAL entry in the important-changes history now
names the restriction classs in its comment. This change introduces a
link to the specific page in django admin for users with Admin:Advanced.
Those without will just see the plain text message.
@jasonBirchall
jasonBirchall requested review from a team, chrstinalin, diox and nothingrandom and removed request for a team, diox and nothingrandom September 10, 2026 14:22

@chrstinalin chrstinalin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WFM

FYI, the Testing section is usually used to outline the steps to take locally 馃槅 But I got it from context clues here.

{% for history_id in record.details.restriction_history_ids %}
{% set entry = restriction_history_by_id.get(history_id) %}
{% if entry %}
<li class="light history-comment">

@chrstinalin chrstinalin Sep 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<li class="light history-comment">
<li class="light">

The extra class messes with the padding

Image Image Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Show which restriction instance(s) caused content to enter a moderation queue

2 participants