Skip to content

Commit

Permalink
list: Check permissions when showing ghost translations
Browse files Browse the repository at this point in the history
This avoids getting permission denied later.

Fixes #9425
  • Loading branch information
nijel committed Jul 3, 2023
1 parent 0098d96 commit df4f79a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions weblate/templates/snippets/list-objects.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,16 @@
<tr id="{{ row_id }}">
<td class="actions" rowspan="2">
{% if object.is_ghost %}
{% perm 'translation.add' object.component as user_can_add_translation %}
{% if user_can_add_translation %}
<form action="{% url 'new-language' project=object.component.project.slug component=object.component.slug %}" method="post">
{% csrf_token %}
<input type="hidden" name="lang" value="{{ object.language.code }}" />
<button type="submit" alt="{% trans "Create translation" %}" title="{% trans "Create translation" %}" class="btn btn-link green">{% icon "plus.svg" %}</button>
</form>
{% else %}
<span class="gray" title="{% trans "Cannot add translation right now" %}">{% icon "plus.svg" %}</span>
{% endif %}
{% else %}
{% if translate_url %}
<a href="{{ translate_url }}{% if object.stats.todo %}?q=state:&lt;translated{% endif %}" class="btn btn-link green" title="{% trans "Translate" %}" alt="{% trans "Translate" %}">{% icon "pencil.svg" %}</a>
Expand Down

0 comments on commit df4f79a

Please sign in to comment.