Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 24, 2024
1 parent 9ec33f1 commit e7c3c38
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 133 deletions.
3 changes: 2 additions & 1 deletion weblate/templates/bootstrap3/layout/radioselect.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

{% comment %}Based on crispy original, just adds color field special handling.{% endcomment %}

<div class="controls {{ field_class }}"{% if flat_attrs %} {{ flat_attrs }}{% endif %}>
<div class="controls {{ field_class }}"
{% if flat_attrs %}{{ flat_attrs }}{% endif %}>
{% include 'bootstrap3/layout/field_errors_block.html' %}

{% for group, options, index in field|optgroups %}
Expand Down
10 changes: 8 additions & 2 deletions weblate/templates/bootstrap3/layout/radioselect_access.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
</label>
{% endif %}

<div class="controls {% if "disabled" in flat_attrs %}access-control-disabled{% endif %} {{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
<div class="controls {% if "disabled" in flat_attrs %}access-control-disabled{% endif %} {{ field_class }}"
{% if flat_attrs %}{{ flat_attrs|safe }}{% endif %}>
{% include 'bootstrap3/layout/field_errors_block.html' %}
<div class="row">
{% for choice in field.field.choices %}
Expand All @@ -25,7 +26,12 @@
<label for="id_{{ field.html_name }}_{{ forloop.counter }}"
class="{% if inline_class %}radio-{{ inline_class }}{% endif %}">
<h5>
<input type="radio"{% if choice_str == field.value|default_if_none:""|stringformat:"s" %} checked="checked"{% endif %} name="{{ field.html_name }}" id="id_{{ field.html_name }}_{{ forloop.counter }}" value="{{ choice.0|unlocalize }}" {{ field.field.widget.attrs|flatatt }}>
<input type="radio"
{% if choice_str == field.value|default_if_none:""|stringformat:"s" %}checked="checked"{% endif %}
name="{{ field.html_name }}"
id="id_{{ field.html_name }}_{{ forloop.counter }}"
value="{{ choice.0|unlocalize }}"
{{ field.field.widget.attrs|flatatt }}>
{% with image_name="access/"|add:choice_str|add:".svg" %}
<img class="access-icon" src="{% static image_name %}" />
{% endwith %}
Expand Down
268 changes: 141 additions & 127 deletions weblate/templates/snippets/list-objects.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,155 +157,169 @@
{% if not hide_details %}
{% list_objects_number value=category.stats.todo search_url=search_url translate_url=translate_url query="q=state:<translated " css="zero-width-640" %} {% list_objects_number value=category.stats.todo_words search_url=search_url translate_url=translate_url query="q=state:<translated" css="zero-width-720" %} {% list_objects_number value=category.stats.todo_chars search_url=search_url translate_url=translate_url query="q=state:<translated" css="zero-width-1200" %} {% list_objects_number value=category.stats.nottranslated search_url=search_url translate_url=translate_url query="q=state:empty" css="zero-width-1400" %} {% list_objects_number value=category.stats.allchecks search_url=search_url translate_url=translate_url query="q=has:check" css="zero-width-768" %} {% list_objects_number value=category.stats.suggestions search_url=search_url translate_url=translate_url query="q=has:suggestion#suggestions" css="zero-width-900" %} {% list_objects_number value=category.stats.comments search_url=search_url translate_url=translate_url query="q=has:comment#comments" css="zero-width-1000" %}
{% endif %}
</tr> <tr data-parent="{{ row_id }}"> <td colspan="7" class="progress-row autocolspan">{% translation_progress category.stats %}</td> </tr>
</tr>
<tr data-parent="{{ row_id }}">
<td colspan="7" class="progress-row autocolspan">{% translation_progress category.stats %}</td>
</tr>
{% endfor %}
{% init_unique_row_id %}
{% for object in objects %}
{% get_translate_url object as translate_url %} {% get_browse_url object as browse_url %} {% get_search_url object as search_url %} {% get_unique_row_id object as row_id %} <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' path=object.component.get_url_path %}"
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 %}
{% get_translate_url object as translate_url %} {% get_browse_url object as browse_url %} {% get_search_url object as search_url %} {% get_unique_row_id object as row_id %}
<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' path=object.component.get_url_path %}"
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 %}

{% 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>
{% else %}
<a href="{{ browse_url }}"
class="btn btn-link green"
title="{% trans "Browse" %}"
alt="{% trans "Browse" %}">{% icon "folder-outline.svg" %}</a>
{% endif %}
{% else %}

{% endif %}
</td> <th class="object-link">
{% if name_source == "component_name" or name_source == "translation" %}
{% 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>
{% else %}
<a href="{{ browse_url }}"
class="btn btn-link green"
title="{% trans "Browse" %}"
alt="{% trans "Browse" %}">{% icon "folder-outline.svg" %}</a>
{% endif %}

{% include "snippets/component-glossary-badge.html" with object=object.component %}
{% endif %}
</td>
<th class="object-link">
{% if name_source == "component_name" or name_source == "translation" %}

{% else %}
{% include "snippets/component-glossary-badge.html" with object=object.component %}

{% include "snippets/component-glossary-badge.html" %}
{% else %}

{% endif %}
{% include "snippets/component-glossary-badge.html" %}

{% if object.is_ghost %}
<span class="ghost">
{% if name_source == "language" %}
{{ object.language }}
{% elif name_source == "component_name" %}
{{ object.component.name }}
{% elif name_source == "name" %}
{{ object.name }}
{% elif name_source == "language" %}
{{ object.language }}
{% elif name_source == "project" %}
{{ object.project }}
{% else %}
{{ object }}
{% endif %}
</span>
{% elif name_source == "translation" %}
<a href="{{ object.component.project.get_absolute_url }}">{{ object.component.project.name }}</a>/<a href="{{ object.component.get_absolute_url }}">{{ object.component.name }}</a><a class="tail" href="{{ browse_url }}">{{ object.language }}</a>
{% else %}
<a href="{{ browse_url }}">
{% spaceless %}
{% endif %}

{% if name_source == "language" %}
{{ object.language }}
{% elif name_source == "component_name" %}
{{ object.component.name }}
{% elif name_source == "name" %}
{{ object.name }}
{% elif name_source == "language" %}
{{ object.language }}
{% elif name_source == "project" %}
{{ object.project }}
{% if object.is_ghost %}
<span class="ghost">
{% if name_source == "language" %}
{{ object.language }}
{% elif name_source == "component_name" %}
{{ object.component.name }}
{% elif name_source == "name" %}
{{ object.name }}
{% elif name_source == "language" %}
{{ object.language }}
{% elif name_source == "project" %}
{{ object.project }}
{% else %}
{{ object }}
{% endif %}
</span>
{% elif name_source == "translation" %}
<a href="{{ object.component.project.get_absolute_url }}">{{ object.component.project.name }}</a>/<a href="{{ object.component.get_absolute_url }}">{{ object.component.name }}</a><a class="tail" href="{{ browse_url }}">{{ object.language }}</a>
{% else %}
{{ object }}
{% endif %}
<a href="{{ browse_url }}">
{% spaceless %}

{% endspaceless %}
</a>
{% endif %}
{% indicate_alerts object %}
{% if custom_workflows and object.pk in custom_workflows %}
<span class="badge">{% translate "Customized workflow" %}</span>
{% endif %}
</th>
{% if project and project.enable_review %}
{% review_percent object.stats %}
{% endif %}
{% if name_source == "language" %}
{{ object.language }}
{% elif name_source == "component_name" %}
{{ object.component.name }}
{% elif name_source == "name" %}
{{ object.name }}
{% elif name_source == "language" %}
{{ object.language }}
{% elif name_source == "project" %}
{{ object.project }}
{% else %}
{{ object }}
{% endif %}

{% if is_glossary %}
{% list_objects_number value=object.stats.translated search_url=search_url translate_url=translate_url query="q=state:>=translated" show_zero=True %}
{% else %}
{% list_objects_percent percent=object.stats.translated_percent value=object.stats.translated search_url=search_url translate_url=translate_url query="q=state:>=translated" total=object.stats.all %}
{% endif %}
{% if not hide_details %}
{% list_objects_number value=object.stats.todo search_url=search_url translate_url=translate_url query="q=state:<translated" css="zero-width-640" %}
{% list_objects_number value=object.stats.todo_words search_url=search_url translate_url=translate_url query="q=state:<translated" css="zero-width-720" %}
{% list_objects_number value=object.stats.todo_chars search_url=search_url translate_url=translate_url query="q=state:<translated" css="zero-width-1200" %}
{% list_objects_number value=object.stats.nottranslated search_url=search_url translate_url=translate_url query="q=state:empty" css="zero-width-1400" %}
{% list_objects_number value=object.stats.allchecks search_url=search_url translate_url=translate_url query="q=has:check" css="zero-width-768" %}
{% list_objects_number value=object.stats.suggestions search_url=search_url translate_url=translate_url query="q=has:suggestion#suggestions" css="zero-width-900" %}
{% list_objects_number value=object.stats.comments search_url=search_url translate_url=translate_url query="q=has:comment#comments" css="zero-width-1000" %}
{% endif %}
</tr>
<tr data-parent="{{ row_id }}">
<td colspan="7" class="progress-row autocolspan">{% translation_progress object.stats %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endspaceless %}
</a>
{% endif %}
{% indicate_alerts object %}
{% if custom_workflows and object.pk in custom_workflows %}
<span class="badge">{% translate "Customized workflow" %}</span>
{% endif %}
</th>
{% if project and project.enable_review %}
{% review_percent object.stats %}
{% endif %}

{% if is_glossary %}
{% list_objects_number value=object.stats.translated search_url=search_url translate_url=translate_url query="q=state:>=translated" show_zero=True %}
{% else %}
{% list_objects_percent percent=object.stats.translated_percent value=object.stats.translated search_url=search_url translate_url=translate_url query="q=state:>=translated" total=object.stats.all %}
{% endif %}
{% if not hide_details %}
{% list_objects_number value=object.stats.todo search_url=search_url translate_url=translate_url query="q=state:<translated" css="zero-width-640" %}
{% list_objects_number value=object.stats.todo_words search_url=search_url translate_url=translate_url query="q=state:<translated" css="zero-width-720" %}
{% list_objects_number value=object.stats.todo_chars search_url=search_url translate_url=translate_url query="q=state:<translated" css="zero-width-1200" %}
{% list_objects_number value=object.stats.nottranslated search_url=search_url translate_url=translate_url query="q=state:empty" css="zero-width-1400" %}
{% list_objects_number value=object.stats.allchecks search_url=search_url translate_url=translate_url query="q=has:check" css="zero-width-768" %}
{% list_objects_number value=object.stats.suggestions search_url=search_url translate_url=translate_url query="q=has:suggestion#suggestions" css="zero-width-900" %}
{% list_objects_number value=object.stats.comments search_url=search_url translate_url=translate_url query="q=has:comment#comments" css="zero-width-1000" %}
{% endif %}
</tr>
<tr data-parent="{{ row_id }}">
<td colspan="7" class="progress-row autocolspan">{% translation_progress object.stats %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>
<em>
{% if empty_message %}
{{ empty_message }}
{% else %}
{% trans "Nothing to list here." %}
{% endif %}
</em>
</p>
<p>
<em>
{% if empty_message %}
{{ empty_message }}
{% else %}
{% trans "Nothing to list here." %}
{% endif %}
</em>
</p>

<p>
{% if add_link == "translation" %}
{% if user_can_add_translation %}
<a class="btn btn-primary"
id="list-add-button"
href="{% url "new-language" path=object.get_url_path %}">{% trans "Start new translation" %}</a>
{% else %}
<a class="btn btn-primary" id="list-add-button" disabled href="#" title="{% if user.is_authenticated %}{% trans "You don't have permission to start a new translation" %}{% else %}{% trans "Please sign in to start new translation" %}{% endif %}">{% trans "Start new translation" %}</a>
{% endif %}
{% elif add_link == "component" %}
{% if user_can_edit_project %}
{% if object.project %}
<p>
{% if add_link == "translation" %}
{% if user_can_add_translation %}
<a class="btn btn-primary"
id="list-add-button"
href="{% url 'create-component' %}?project={{ object.project.pk }}&amp;category={{ object.pk }}">{% trans "Add new translation component" %}</a>
href="{% url "new-language" path=object.get_url_path %}">{% trans "Start new translation" %}</a>
{% else %}
<a class="btn btn-primary"
id="list-add-button"
href="{% url 'create-component' %}?project={{ object.pk }}">{% trans "Add new translation component" %}</a>
disabled
href="#"
title="{% if user.is_authenticated %}{% trans "You don't have permission to start a new translation" %}{% else %}{% trans "Please sign in to start new translation" %}{% endif %}">{% trans "Start new translation" %}</a>
{% endif %}
{% elif add_link == "component" %}
{% if user_can_edit_project %}
{% if object.project %}
<a class="btn btn-primary"
id="list-add-button"
href="{% url 'create-component' %}?project={{ object.project.pk }}&amp;category={{ object.pk }}">{% trans "Add new translation component" %}</a>
{% else %}
<a class="btn btn-primary"
id="list-add-button"
href="{% url 'create-component' %}?project={{ object.pk }}">{% trans "Add new translation component" %}</a>
{% endif %}
{% endif %}
{% elif add_link == "language" %}
{% if user_can_add_language %}
<a class="btn btn-primary" id="list-add-button" href="{% url 'create-language' %}">{% trans "Add language" %}</a>
{% endif %}
{% endif %}
{% elif add_link == "language" %}
{% if user_can_add_language %}
<a class="btn btn-primary" id="list-add-button" href="{% url 'create-language' %}">{% trans "Add language" %}</a>
{% endif %}
{% endif %}
</p>
</p>

{% endif %}
6 changes: 3 additions & 3 deletions weblate/templates/trans/embed-alert.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
{% for icon, text, url in icons %}
{% spaceless %}
{% if url %}<a href="{{ url }}">{% endif %}
<span class="state-icon {% if icon == "state/ghost.svg" %} grey{% elif icon == "state/alert.svg" %} red{% endif %}" title="{{ text }}" alt="{{ text }}">
{% icon icon %}
</span>
<span class="state-icon {% if icon == "state/ghost.svg" %} grey{% elif icon == "state/alert.svg" %} red{% endif %}"
title="{{ text }}"
alt="{{ text }}">{% icon icon %}</span>
{% if url %}</a>{% endif %}
{% endspaceless %}
{% endfor %}
Expand Down

0 comments on commit e7c3c38

Please sign in to comment.