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
7d5b36ff
Commit
7d5b36ff
authored
Apr 17, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate trans.edit_flags permission check to new model
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
6310ea7d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
4 deletions
+25
-4
weblate/html/js/detail.html
weblate/html/js/detail.html
+3
-1
weblate/html/translate.html
weblate/html/translate.html
+3
-2
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/source.py
weblate/trans/views/source.py
+6
-1
No files found.
weblate/html/js/detail.html
View file @
7d5b36ff
...
...
@@ -2,6 +2,8 @@
{% load i18n %}
{% load crispy_forms_tags %}
{% can_edit_flags user unit.translation.subproject.project as user_can_edit_flags %}
<div
class=
"row"
>
<div
class=
"col-lg-6"
>
<table
class=
"table table-condensed table-striped"
>
...
...
@@ -28,7 +30,7 @@
<div
class=
"col-lg-6"
>
<table
class=
"table table-condensed"
>
{% if
perms.trans.
edit_flags %}
{% if
user_can_
edit_flags %}
<tr>
<td>
<div
class=
"btn-group pull-right flip"
>
...
...
weblate/html/translate.html
View file @
7d5b36ff
...
...
@@ -24,6 +24,7 @@
{% can_delete_suggestion user unit.translation as user_can_delete_suggestion %}
{% can_vote_suggestion user unit.translation as user_can_vote_suggestion %}
{% can_use_mt user unit.translation as user_can_use_mt %}
{% can_edit_flags user unit.translation.subproject.project as user_can_edit_flags %}
{% if user_can_translate %}
<a
href=
"{% url 'zen' project=unit.translation.subproject.project.slug subproject=unit.translation.subproject.slug lang=unit.translation.language.code %}?sid={{ search_id }}"
title=
"{% trans "
Edit
in
Zen
mode
"
%}"
class=
"btn btn-default pull-right flip"
><i
class=
"fa fa-arrows-alt"
></i>
{% trans "Zen" %}
</a>
...
...
@@ -391,14 +392,14 @@
<td>
{% format_translation unit.context search_match=search_query simple=True %}
</td>
</tr>
{% endif %}
{% if unit.flags or
perms.trans.
edit_flags %}
{% if unit.flags or
user_can_
edit_flags %}
<tr>
<th>
{% trans "Flags" %}
</th>
</tr>
<tr>
<td>
{{ unit.all_flags|join:", " }}
{% if
perms.trans.
edit_flags %}
<a
class=
"button smallbutton"
href=
"{% url 'review_source' project=unit.translation.subproject.project.slug subproject=unit.translation.subproject.slug %}?checksum={{ unit.checksum }}"
><i
class=
"fa fa-pencil"
></i></a>
{% endif %}
{% if
user_can_
edit_flags %}
<a
class=
"button smallbutton"
href=
"{% url 'review_source' project=unit.translation.subproject.project.slug subproject=unit.translation.subproject.slug %}?checksum={{ unit.checksum }}"
><i
class=
"fa fa-pencil"
></i></a>
{% endif %}
</td>
</tr>
{% endif %}
...
...
weblate/trans/permissions.py
View file @
7d5b36ff
...
...
@@ -200,3 +200,11 @@ def can_lock_subproject(user, project):
Checks whether user can lock translation subproject.
"""
return
check_permission
(
user
,
project
,
'trans.lock_subproject'
)
@
cache_permission
def
can_edit_flags
(
user
,
project
):
"""
Checks whether user can edit translation flags.
"""
return
check_permission
(
user
,
project
,
'trans.edit_flags'
)
weblate/trans/templatetags/permissions.py
View file @
7d5b36ff
...
...
@@ -91,3 +91,8 @@ def can_reset_translation(user, project):
@
register
.
assignment_tag
def
can_lock_subproject
(
user
,
project
):
return
weblate
.
trans
.
permissions
.
can_lock_subproject
(
user
,
project
)
@
register
.
assignment_tag
def
can_edit_flags
(
user
,
project
):
return
weblate
.
trans
.
permissions
.
can_edit_flags
(
user
,
project
)
weblate/trans/views/source.py
View file @
7d5b36ff
...
...
@@ -21,6 +21,7 @@
from
django.http
import
Http404
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
from
django.contrib.auth.decorators
import
permission_required
from
django.core.exceptions
import
PermissionDenied
from
django.contrib.auth.decorators
import
login_required
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -31,6 +32,7 @@ from urllib import urlencode
from
weblate.trans.views.helper
import
get_subproject
from
weblate.trans.models
import
Translation
,
Source
from
weblate.trans.forms
import
PriorityForm
,
CheckFlagsForm
from
weblate.trans.permissions
import
can_edit_flags
def
get_source
(
request
,
project
,
subproject
):
...
...
@@ -131,12 +133,15 @@ def edit_priority(request, pk):
@
require_POST
@
login_required
@
permission_required
(
'trans.edit_check_flags'
)
def
edit_check_flags
(
request
,
pk
):
"""
Change source string check flags.
"""
source
=
get_object_or_404
(
Source
,
pk
=
pk
)
if
not
can_edit_flags
(
request
.
user
,
source
.
subproject
.
project
):
raise
PermissionDenied
()
form
=
CheckFlagsForm
(
request
.
POST
)
if
form
.
is_valid
():
source
.
check_flags
=
form
.
cleaned_data
[
'flags'
]
...
...
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