on trie les tags sur les événements

This commit is contained in:
Jean-Marie Favreau 2024-11-20 13:07:08 +01:00
parent 283ffc4348
commit c4bb86dab4
7 changed files with 14 additions and 6 deletions

View File

@ -689,6 +689,14 @@ class Event(models.Model):
verbose_name_plural = _("Events")
permissions = [("set_duplicated_event", "Can set an event as duplicated")]
def sorted_tags(self):
if self.tags is None:
return []
else:
result = self.tags
result.sort(key=lambda x: emoji.demojize(remove_accents(x.lower()), delimiters=('000', '')))
return result
def get_all_tags(sort=True):
cursor = connection.cursor()
raw_query = """

View File

@ -55,7 +55,7 @@
<p>
{% for tag in event.tags %}
{% for tag in event.sorted_tags %}
{{ tag | tag_button }}
{% endfor %}
</p>

View File

@ -56,7 +56,7 @@
{% endif %}
<div class="infos">
<p>
{% for tag in event.tags %}
{% for tag in event.sorted_tags %}
<a href="{% url 'view_tag' tag|prepare_tag %}" role="button" class="small-cat">{{ tag|tw_highlight }}</a>
{% endfor %}
</p>

View File

@ -36,7 +36,7 @@
{% if event.tags %}
<p class="subentry-search">
{% picto_from_name "tag" %}
{% for tag in event.tags %}
{% for tag in event.sorted_tags %}
<a href="{% url 'view_tag' tag|prepare_tag %}">{{ tag|tw_highlight }}</a>
{% if not forloop.last %}, {% endif %}
{% endfor %}

View File

@ -38,7 +38,7 @@
{% if event.tags and event.tags|length > 0 %}
<p>
{% picto_from_name "tag" %}
{% for tag in event.tags %}
{% for tag in event.sorted_tags %}
<a href="{% url 'view_tag' tag|prepare_tag %}">{{ tag|tw_highlight }}</a>
{% if not forloop.last %}, {% endif %}
{% endfor %}

View File

@ -28,7 +28,7 @@
<p>
{% for tag in event.tags %}
{% for tag in event.sorted_tags %}
{{ tag | tag_button }}
{% endfor %}
</p>

View File

@ -65,7 +65,7 @@
<div class="infos">
<p>
{% for tag in event.tags %}
{% for tag in event.sorted_tags %}
<a href="{% url 'view_tag' tag|prepare_tag %}" role="button" class="small-cat">{{ tag|tw_highlight }}</a>
{% endfor %}
</p>