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
3bc7ce6b
Commit
3bc7ce6b
authored
Apr 16, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add wrapper for suggestion privileges
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
316339f6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
14 deletions
+23
-14
weblate/html/translate.html
weblate/html/translate.html
+3
-4
weblate/trans/permissions.py
weblate/trans/permissions.py
+11
-0
weblate/trans/templatetags/permissions.py
weblate/trans/templatetags/permissions.py
+7
-0
weblate/trans/views/edit.py
weblate/trans/views/edit.py
+2
-10
No files found.
weblate/html/translate.html
View file @
3bc7ce6b
...
...
@@ -5,6 +5,7 @@
{% load crispy_forms_tags %}
{% load permissions %}
{% can_translate request.user unit.translation as user_can_translate %}
{% can_suggest request.user unit.translation as user_can_suggest %}
{% block extra_meta %}
...
...
@@ -94,13 +95,11 @@
{% endwith %}
{% endif %}
{% if unit.translation.subproject.enable_suggestions %}
{% if perms.trans.add_suggestion %}
{% if user_can_suggest %}
<input
class=
"btn btn-default"
type=
"submit"
value=
"{% trans "
Suggest
"
%}"
name=
"suggest"
tabindex=
"151"
{%
if
project_locked
%}
disabled=
"disabled"
{%
endif
%}
/>
{% else %}
{% trans "No privileges for adding suggestions!" %}
{% endif %}
{% endif %}
{% if user_can_translate %}
<div
class=
"pull-right flip hidden-xs"
>
...
...
@@ -362,7 +361,7 @@
<td>
{{ item.source }}
</td>
<td
class=
"target"
>
{% format_translation item.target unit.translation.language simple=True %}
</td>
<td>
{% if user_can_translate or
perms.trans.add_suggestion
%}
{% if user_can_translate or
user_can_suggest
%}
<a
class=
"copydict btn btn-default btn-xs"
title=
"{% trans "
Copy
word
to
translation
"
%}"
>
{% trans "Copy" %}
</a>
{% endif %}
</td>
...
...
weblate/trans/permissions.py
View file @
3bc7ce6b
...
...
@@ -36,3 +36,14 @@ def can_translate(user, translation):
user
.
has_perm
(
'trans.override_suggestion'
)):
return
False
return
True
def
can_suggest
(
user
,
translation
):
"""
Checks whether user can add suggestions to given translation.
"""
if
not
translation
.
subproject
.
enable_suggestions
:
return
False
if
not
user
.
has_perm
(
'trans.add_translation'
):
return
False
return
True
weblate/trans/templatetags/permissions.py
View file @
3bc7ce6b
...
...
@@ -28,3 +28,10 @@ def can_translate(user, translation):
return
weblate
.
trans
.
permissions
.
can_translate
(
user
,
translation
)
@
register
.
assignment_tag
def
can_suggest
(
user
,
translation
):
return
weblate
.
trans
.
permissions
.
can_suggest
(
user
,
translation
)
weblate/trans/views/edit.py
View file @
3bc7ce6b
...
...
@@ -41,7 +41,7 @@ from weblate.trans.forms import (
from
weblate.trans.views.helper
import
get_translation
from
weblate.trans.checks
import
CHECKS
from
weblate.trans.util
import
join_plural
from
weblate.trans.permissions
import
can_translate
from
weblate.trans.permissions
import
can_translate
,
can_suggest
def
cleanup_session
(
session
):
...
...
@@ -176,7 +176,7 @@ def perform_suggestion(unit, form, request):
messages
.
error
(
request
,
_
(
'Your suggestion is empty!'
))
# Stay on same entry
return
False
elif
not
request
.
user
.
has_perm
(
'trans.add_suggestion'
):
elif
can_suggest
(
request
.
user
,
unit
.
translation
):
# Need privilege to add
messages
.
error
(
request
,
...
...
@@ -184,14 +184,6 @@ def perform_suggestion(unit, form, request):
)
# Stay on same entry
return
False
elif
not
unit
.
translation
.
subproject
.
enable_suggestions
:
# Need privilege to add
messages
.
error
(
request
,
_
(
'Suggestions are not allowed on this translation!'
)
)
# Stay on same entry
return
False
# Invite user to become translator if there is nobody else
recent_changes
=
Change
.
objects
.
content
(
True
).
filter
(
translation
=
unit
.
translation
,
...
...
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