Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
cade73fa
Commit
cade73fa
authored
Apr 17, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate trans.delete_comment permission check to new model
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
90ff5df2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
2 deletions
+24
-2
weblate/html/list-checks.html
weblate/html/list-checks.html
+2
-0
weblate/html/list-comments.html
weblate/html/list-comments.html
+4
-1
weblate/trans/permissions.py
weblate/trans/permissions.py
+8
-0
weblate/trans/templatetags/permissions.py
weblate/trans/templatetags/permissions.py
+5
-0
weblate/trans/views/edit.py
weblate/trans/views/edit.py
+5
-1
No files found.
weblate/html/list-checks.html
View file @
cade73fa
{% load i18n %}
{% load permissions %}
{% can_ignore_check user check.project as user_can_ignore_check %}
{% for check in checks %}
...
...
weblate/html/list-comments.html
View file @
cade73fa
{% load translations %}
{% load i18n %}
{% load permissions %}
{% can_delete_comment user unit.translation.subproject.project as user_can_delete_comment %}
{% for comment in comments %}
<div>
...
...
@@ -13,7 +16,7 @@
{% endif %}
</span>
</div>
{% if
perms.trans.
delete_comment %}
{% if
user_can_
delete_comment %}
<form
method=
"POST"
action=
"{% url 'delete-comment' pk=comment.pk %}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"next"
value=
"{{ next_url }}"
/>
...
...
weblate/trans/permissions.py
View file @
cade73fa
...
...
@@ -224,3 +224,11 @@ def can_ignore_check(user, project):
Checks whether user can edit translation priority.
"""
return
check_permission
(
user
,
project
,
'trans.ignore_check'
)
@
cache_permission
def
can_delete_comment
(
user
,
project
):
"""
Checks whether user can edit translation priority.
"""
return
check_permission
(
user
,
project
,
'trans.delete_comment'
)
weblate/trans/templatetags/permissions.py
View file @
cade73fa
...
...
@@ -106,3 +106,8 @@ def can_edit_priority(user, project):
@
register
.
assignment_tag
def
can_ignore_check
(
user
,
project
):
return
weblate
.
trans
.
permissions
.
can_ignore_check
(
user
,
project
)
@
register
.
assignment_tag
def
can_delete_comment
(
user
,
project
):
return
weblate
.
trans
.
permissions
.
can_delete_comment
(
user
,
project
)
weblate/trans/views/edit.py
View file @
cade73fa
...
...
@@ -25,6 +25,7 @@ from django.http import HttpResponseRedirect, HttpResponse
from
django.contrib
import
messages
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.utils
import
formats
from
django.core.exceptions
import
PermissionDenied
import
uuid
import
time
...
...
@@ -43,7 +44,7 @@ from weblate.trans.checks import CHECKS
from
weblate.trans.util
import
join_plural
from
weblate.trans.permissions
import
(
can_translate
,
can_suggest
,
can_accept_suggestion
,
can_delete_suggestion
,
can_vote_suggestion
,
can_vote_suggestion
,
can_delete_comment
,
)
...
...
@@ -693,6 +694,9 @@ def delete_comment(request, pk):
comment_obj
=
get_object_or_404
(
Comment
,
pk
=
pk
)
comment_obj
.
project
.
check_acl
(
request
)
if
not
can_delete_comment
(
request
.
user
,
comment_obj
.
project
):
raise
PermissionDenied
()
units
=
get_related_units
(
comment_obj
)
if
units
.
exists
():
fallback_url
=
units
[
0
].
get_absolute_url
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment