Commit bcef5768 authored by Michal Čihař's avatar Michal Čihař

Migrate trans.ignore_check permission check to new model

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent c65940b4
{% load i18n %}
{% can_ignore_check user check.project as user_can_ignore_check %}
{% for check in checks %}
<div data-href="{% url 'js-ignore-check' check_id=check.id %}" class="alert alert-{{ check.get_severity }} {% if perms.trans.ignore_check %}alert-dismissable{% endif %} check tooltip-control" id="check-{{ check.id }}" title="{{ check.get_description }}">
{% if perms.trans.ignore_check %}
<div data-href="{% url 'js-ignore-check' check_id=check.id %}" class="alert alert-{{ check.get_severity }} {% if user_can_ignore_check %}alert-dismissable{% endif %} check tooltip-control" id="check-{{ check.id }}" title="{{ check.get_description }}">
{% if user_can_ignore_check %}
<button type="button" class="close" data-dismiss="alert" title="{% blocktrans with check.get_check_display as check %}Ignore: {{ check }}{% endblocktrans %}">&times;</button>
{% endif %}
<a href="{{ check.get_doc_url }}" class="alert-link">{{ check.get_check_display }}</a>
......
......@@ -216,3 +216,11 @@ def can_edit_priority(user, project):
Checks whether user can edit translation priority.
"""
return check_permission(user, project, 'trans.edit_priority')
@cache_permission
def can_ignore_check(user, project):
"""
Checks whether user can edit translation priority.
"""
return check_permission(user, project, 'trans.ignore_check')
......@@ -101,3 +101,8 @@ def can_edit_flags(user, project):
@register.assignment_tag
def can_edit_priority(user, project):
return weblate.trans.permissions.can_edit_priority(user, project)
@register.assignment_tag
def can_ignore_check(user, project):
return weblate.trans.permissions.can_ignore_check(user, project)
......@@ -119,9 +119,13 @@ def get_unit_changes(request, unit_id):
)
@permission_required('trans.ignore_check')
@login_required
def ignore_check(request, check_id):
obj = get_object_or_404(Check, pk=int(check_id))
if not can_ignore_check(request.user, obj.project):
raise PermissionDenied()
obj.project.check_acl(request)
# Mark check for ignoring
obj.set_ignore()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment