Commit 34ace2c5 authored by Michal Čihař's avatar Michal Čihař

Permission based access to machine translation

Admin can now customize who can use machine translation, it is not
longer only allowed for logged in users.
parent 54928e54
......@@ -592,6 +592,7 @@ def create_groups(update):
Permission.objects.get(codename='can_see_git_repository'),
Permission.objects.get(codename='add_comment'),
Permission.objects.get(codename='add_suggestion'),
Permission.objects.get(codename='use_mt'),
)
group, created = Group.objects.get_or_create(name='Managers')
......@@ -621,6 +622,7 @@ def create_groups(update):
Permission.objects.get(codename='add_comment'),
Permission.objects.get(codename='delete_comment'),
Permission.objects.get(codename='add_suggestion'),
Permission.objects.get(codename='use_mt'),
)
try:
......
......@@ -403,6 +403,8 @@ Can lock translation for translating [Users, Managers]
Can lock translation while translating (see :ref:`locking`).
Can add suggestion [Users, Managers, Guests]
Can add new suggestions.
Can use machine translation [Users, Managers]
Can use machine translations (see :ref:`machine-translation-setup`).
The default setup (after you run :djadmin:`setupgroups`) consists of three
groups `Guests`, `Users` and `Managers` which have privileges as described
......
......@@ -153,6 +153,7 @@ class Translation(models.Model, URLMixin, PercentMixin):
('reset_translation', "Can reset translations to match remote"),
('automatic_translation', "Can do automatic translation"),
('lock_translation', "Can lock whole translation project"),
('use_mt', "Can use machine translation"),
)
app_label = 'trans'
......
......@@ -47,7 +47,7 @@ def get_string(request, checksum):
return HttpResponse(units[0].get_source_plurals()[0])
@login_required
@permission_required('trans.use_mt')
def translate(request, unit_id):
'''
AJAX handler for translating.
......
......@@ -186,7 +186,7 @@
<li><a href="#tab-nearby" title="{% trans "Messages placed around this one" %}">{% trans "Nearby messages" %}</a></li>
<li><a href="{% url 'js-other' unit_id=unit.id %}?type={{ type }}&amp;offset={{ offset }}&amp;sid={{ search_id }}" title="{% trans "Same message used in different subprojects" %}">{% trans "All locations" %}</a></li>
<li><a href="{% url 'js-dictionary' unit_id=unit.id %}" title="{% trans "Words extracted from glossary" %}">{% trans "Glossary" %}</a></li>
{% if mt_enabled and user.is_authenticated %}
{% if mt_enabled and perms.trans.use_mt %}
<li><a href="#tab-machine" title="{% trans "Machine translation suggestions" %}">{% trans "Machine translation" %}</a></li>
{% endif %}
<li><a href="#tab-comments" title="{% trans "Comments about this translation" %}">
......@@ -223,7 +223,7 @@
</tbody>
</table>
</div>
{% if mt_enabled and user.is_authenticated %}
{% if mt_enabled and perms.trans.use_mt %}
<div id="tab-machine">
<img src="{% get_media_prefix %}loading.gif" id="mt-loading" style="display: none" />
<table>
......
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