-
Notifications
You must be signed in to change notification settings - Fork 535
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
Update link to ratings in reviewer tools for disabled addons. #15751
Conversation
@eviljeff Please review |
{# Using num=count so we don't change an L10n string. #} | ||
{% if not addon.is_disabled or action_allowed(amo.permissions.RATINGS_MODERATE) %} | ||
{% set review_url = url('addons.ratings.list', addon.slug) %} | ||
{% if addon.is_disabled %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want this always when the user has the permission
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see the original comment in the issue - the two alternatives are having the permission and not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to only linkify if the user has permission Ratings:Moderate
, otherwise leave it unlinked. Is it right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need some tests that prove your changes work.
TestReview.test_user_ratings
can be added to, perhaps, to check the link is there. And there should be a new test to check the link isn't there when the user doens't have the correct permission.
{# Using num=count so we don't change an L10n string. #} | ||
{% if acl_is_review_moderator %} | ||
{% set review_url = url('admin:ratings_rating_changelist')|urlparams(addon=addon.pk) %} | ||
<a href="{{ review_url|absolutify }}"><strong>{{ | ||
ngettext('{num} review', '{num} reviews', num)|format_html(num=count) | ||
}}</strong></a> | ||
{% else %} | ||
<strong>{{ | ||
ngettext('{num} review', '{num} reviews', num)|format_html(num=count) | ||
}}</strong> | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to have to define the same string twice, so we should also define it separately, like:
{# Using num=count so we don't change an L10n string. #} | |
{% if acl_is_review_moderator %} | |
{% set review_url = url('admin:ratings_rating_changelist')|urlparams(addon=addon.pk) %} | |
<a href="{{ review_url|absolutify }}"><strong>{{ | |
ngettext('{num} review', '{num} reviews', num)|format_html(num=count) | |
}}</strong></a> | |
{% else %} | |
<strong>{{ | |
ngettext('{num} review', '{num} reviews', num)|format_html(num=count) | |
}}</strong> | |
{% endif %} | |
{# Using num=count so we don't change an L10n string. #} | |
{% set review_url_text = ngettext('{num} review', '{num} reviews', num)|format_html(num=count) %} | |
{% if acl_is_review_moderator %} | |
{% set review_url = url('admin:ratings_rating_changelist')|urlparams(addon=addon.pk) %} | |
<a href="{{ review_url|absolutify }}"><strong>{{ review_url_text }}</strong></a> | |
{% else %} | |
<strong>{{ review_url_text }}</strong> | |
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, r+
@wagnerand before I merge this, is it really only |
@eviljeff I believe so (https://github.com/mozilla/addons-server/blob/master/src/olympia/constants/permissions.py#L215:L215), unless I am missing something? |
I thought maybe a check that the user was able to actually access django admin ( |
Fixes mozilla/addons#6223
If the addon is public,
X reviews
points to the public ratings pageIf the addon is not public and user has the
Ratings:Moderate
permission, pointing to /admin/models/ratings/rating/?addon=. For users that don't have that permission (ie regular reviewers, they would still see that text, but without a link.PRs open for the same issue.
Fixes #ISSUENUM
at the top of your PR.