FabulaVotes/templates/weeks/editable_truth.tera
trotFunky 76de321d41 templates: Don't show the tagging form if no tags
If there are no tags but the form is still shown, the admin
could ask to add an empty tag returning an error 422
unprocessable entity.
Remove if there are no tags available
2024-08-01 22:55:44 +01:00

32 lines
1.5 KiB
Text

<div class="individual_truth">
<a href="/{{ truth.week }}#{{ truth.number }}"><h3 id="{{ truth.number }}">Vérité {{ truth.number }}</h3></a>
<p>{{ truth.rendered_text | safe }}</p>
<div class="truth_tags">
{% for tag in truth.tags %}
<form action="/{{ week_data.number }}/untag/{{ truth.id }}" method="post">
<button name="name" value="{{ tag.name }}">❌</button>
</form>
<a class="tag" href="/tags/filter?tags={{ tag.name }}" style="background-color: {{ tag.color }}">
{{ tag.name }}
</a>
{% endfor %}
</div>
<hr/>
<form class="truth_edit_form" action="/{{ week_data.number }}/edit/{{ truth.number }}" method="POST">
{% include "weeks/truth_editor" %}
</form>
{% if tags | length > 0 and tags | length > truth.tags | length %}
<form class="truth_edit_form" action="/{{ week_data.number }}/tag/{{ truth.id }}" method="post">
<label>Thème supplémentaire:
<select name="name">
{% for tag in tags %}
{% if not truth.tags is containing(tag) %}
<option value="{{ tag.name }}" style="background-color: {{ tag.color }}">{{ tag.name }}</option>
{% endif %}
{% endfor %}
</select>
</label>
<button>Ajouter un thème</button>
</form>
{% endif %}
</div>