On interdit les "/" dans les tags

Fix #186
This commit is contained in:
Jean-Marie Favreau 2024-11-06 13:01:47 +01:00
parent 3a01b1caf6
commit 67f7ed9287
9 changed files with 20 additions and 9 deletions

View File

@ -798,6 +798,11 @@ class Event(models.Model):
if self.image and not self.local_image:
self.download_image()
# remove "/" from tags
if self.tags:
self.tags = [t.replace('/', '-') for t in self.tags]
# in case of importation process
if self.is_in_importation_process():
# try to detect location
if not self.exact_location:

View File

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

View File

@ -1,5 +1,6 @@
{% load utils_extra %}
{% load cat_extra %}
{% load tag_extra %}
{% load event_extra %}
<header>{{ event.category | small_cat_recurrent:event.has_recurrences }}
@ -35,7 +36,7 @@
<p class="subentry-search">
{% picto_from_name "tag" %}
{% for tag in event.tags %}
<a href="{% url 'view_tag' tag %}">{{ tag }}</a>
<a href="{% url 'view_tag' tag|prepare_tag %}">{{ tag }}</a>
{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>

View File

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

View File

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

View File

@ -1,6 +1,7 @@
{% load utils_extra %}
{% load cat_extra %}
{% load event_extra %}
{% load tag_extra %}
<header>
<div class="slide-buttons">
@ -36,7 +37,7 @@
<p>
{% picto_from_name "tag" %}
{% for tag in event.tags %}
<a href="{% url 'view_tag' tag %}">{{ tag }}</a>
<a href="{% url 'view_tag' tag|prepare_tag %}">{{ tag }}</a>
{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>

View File

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

View File

@ -26,7 +26,7 @@
{% for tag in tags %}
<article class="tag-description no-image">
<header><a href="{% url 'view_tag' tag.name %}" role="button" class="small-cat">{{ tag.name }}</a></header>
<header><a href="{% url 'view_tag' tag.name|prepare_tag %}" role="button" class="small-cat">{{ tag.name }}</a></header>
<div>
{{ tag.description|safe }}
<p>{% if tag.category %}Cette étiquette est une sous-catégorie de {{ tag.category| small_cat:tag.category.get_absolute_url }}{% endif %}</p>
@ -43,7 +43,7 @@
<div>
{% for tag in other_tags %}
{% if tag|tag_not_in_db:tags %}
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
<a href="{% url 'view_tag' tag|prepare_tag %}" role="button" class="small-cat">{{ tag }}</a>
{% endif %}
{% endfor %}
</div>

View File

@ -34,7 +34,7 @@ def t_button(tag, url, strike=False, category=None):
@register.filter
def tag_button(tag, link=False, strike=False):
return t_button(tag, reverse_lazy("view_tag", kwargs={"t": tag}) if link else None, strike)
return t_button(tag, reverse_lazy("view_tag", kwargs={"t": tag.replace('/', '-')}) if link else None, strike)
@register.filter
@ -65,3 +65,7 @@ def show_suggested_tags(filter):
result += ' ' + t_button(t.name, filter.get_url_add_tag(t.name, t.category), category=t.category)
return mark_safe(result)
@register.filter
def prepare_tag(tag):
return tag.replace('/', '-')