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
ef2e423b
Commit
ef2e423b
authored
Sep 22, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow owners to use automatic translation
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
72c41c5b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
weblate/trans/permissions.py
weblate/trans/permissions.py
+8
-0
weblate/trans/views/basic.py
weblate/trans/views/basic.py
+2
-1
weblate/trans/views/edit.py
weblate/trans/views/edit.py
+8
-3
No files found.
weblate/trans/permissions.py
View file @
ef2e423b
...
...
@@ -261,3 +261,11 @@ def can_download_changes(user, project):
Checks whether user can download CSV for changes on given project.
"""
return
check_permission
(
user
,
project
,
'trans.download_changes'
)
@
cache_permission
def
can_automatic_translation
(
user
,
project
):
"""
Checks whether user can do automatic translation on given project.
"""
return
check_permission
(
user
,
project
,
'trans.automatic_translation'
)
weblate/trans/views/basic.py
View file @
ef2e423b
...
...
@@ -38,6 +38,7 @@ from weblate.trans.forms import (
AutoForm
,
ReviewForm
,
NewLanguageForm
,
UserManageForm
,
)
from
weblate.trans.permissions
import
can_automatic_translation
from
weblate.accounts.models
import
Profile
,
notify_new_language
from
weblate.trans.views.helper
import
(
get_project
,
get_subproject
,
get_translation
,
...
...
@@ -284,7 +285,7 @@ def show_translation(request, project, subproject, lang):
form
=
get_upload_form
(
request
)()
# Is user allowed to do automatic translation?
if
request
.
user
.
has_perm
(
'trans.automatic_translation'
):
if
can_automatic_translation
(
request
.
user
,
obj
.
subproject
.
project
):
autoform
=
AutoForm
(
obj
)
else
:
autoform
=
None
...
...
weblate/trans/views/edit.py
View file @
ef2e423b
...
...
@@ -23,7 +23,7 @@ from django.views.decorators.http import require_POST
from
django.utils.translation
import
ugettext
as
_
from
django.http
import
HttpResponseRedirect
,
HttpResponse
from
django.contrib
import
messages
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.contrib.auth.decorators
import
login_required
from
django.utils
import
formats
from
django.core.exceptions
import
PermissionDenied
import
uuid
...
...
@@ -44,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_delete_comment
,
can_vote_suggestion
,
can_delete_comment
,
can_automatic_translation
,
)
...
...
@@ -599,9 +599,14 @@ def translate(request, project, subproject, lang):
)
@
permission_required
(
'trans.automatic_translation'
)
@
require_POST
@
login_required
def
auto_translation
(
request
,
project
,
subproject
,
lang
):
translation
=
get_translation
(
request
,
project
,
subproject
,
lang
)
project
=
translation
.
subproject
.
project
if
not
can_automatic_translation
(
request
.
user
,
project
):
raise
PermissionDenied
()
translation
.
commit_pending
(
request
)
autoform
=
AutoForm
(
translation
,
request
.
POST
)
change
=
None
...
...
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