Skip to content

Commit

Permalink
Corrige l'incohérence des tags entre la bibliothèque et les billets (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Migwel authored Jun 15, 2022
1 parent f87657b commit d861945
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
{% trans "Tags les plus utilisés" %}
</li>
{% for tag in categories.tags %}
<li><a href="{% url 'publication:list' %}?tag={{ tag.title|urlencode }}">{{ tag }}</a></li>
<li><a href="{% url 'publication:list' %}?tag={{ tag.slug }}">{{ tag }}</a></li>
{% endfor %}
<li><a href="{% url 'content:tags' %}">Tous les tags</a></li>
</ul>
Expand Down Expand Up @@ -139,7 +139,7 @@
{% trans "Tags les plus utilisés" %}
</li>
{% for tag in categories.tags %}
<li><a href="{% url 'opinion:list' %}?tag={{ tag.title|urlencode }}">{{ tag }}</a></li>
<li><a href="{% url 'opinion:list' %}?tag={{ tag.slug }}">{{ tag }}</a></li>
{% endfor %}
<li><a href="{% url 'content:tags' %}?type=opinion">Tous les tags</a></li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions templates/searchv2/includes/publishedcontent.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ <h3 class="content-title" itemprop="itemListElement">
{% for tag in search_result.tags|slice:":3" %}
<li>
{% if search_result.content_type == 'OPINION' %}
<a href="{% url 'opinion:list' %}?tag={{ tag|urlencode }}">{{ tag }}</a>
<a href="{% url 'opinion:list' %}?tag={{ tag.slug }}">{{ tag }}</a>
{% else %}
<a href="{% url 'publication:list' %}?tag={{ tag|urlencode }}">{{ tag }}</a>
<a href="{% url 'publication:list' %}?tag={{ tag.slug }}">{{ tag }}</a>
{% endif %}
</li>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion templates/tutorialv2/includes/content_item.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h3 class="content-title" itemprop="itemListElement">
<ul class="content-tags" itemprop="keywords">
{% for tag in content.tags.all|slice:":3" %}
<li>
<a href="{{ taglist }}?tag={% if content.is_opinion %}{{ tag.title|urlencode }}{% else %}{{ tag.slug }}{% endif %}">
<a href="{{ taglist }}?tag={{ tag.slug }}">
{{ tag.title }}
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion templates/tutorialv2/includes/tags_authors.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
{% if publishablecontent.tags.all|length > 0 %}
<ul class="taglist" itemprop="keywords">
{% for tag in publishablecontent.tags.all %}
<li><a href="{{ taglist }}?tag={% if content.is_opinion %}{{ tag.title|urlencode }}{% else %}{{ tag.slug }}{% endif %}" rel="tag">{{ tag.title }}</a></li>
<li><a href="{{ taglist }}?tag={{ tag.slug }}" rel="tag">{{ tag.title }}</a></li>
{% endfor %}
</ul>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion templates/tutorialv2/view/tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h2 class="ico-after ico-tags">
<div class="content-tags-list">
{% for tag in tags %}
<div class="content-tag">
<a href="{{ url_list }}?tag={% if tags_to_display == 'OPINION' %}{{ tag.title|urlencode }}{% else %}{{ tag.slug }}{% endif %}">
<a href="{{ url_list }}?tag={{ tag.slug }}">
<div class="tag-title">{{ tag }}</div>
<div class="tag-count">
{% blocktrans with tag_count=tag.num_content plural=tag.num_content|pluralize_fr %}
Expand Down
6 changes: 6 additions & 0 deletions zds/tutorialv2/tests/tests_opinion_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.test import TestCase
from django.utils.translation import gettext_lazy as _

from zds.forum.tests.factories import TagFactory
from zds.gallery.tests.factories import UserGalleryFactory
from zds.member.tests.factories import ProfileFactory, StaffProfileFactory
from zds.tutorialv2.tests.factories import (
Expand Down Expand Up @@ -860,3 +861,8 @@ def test_opinion_alert(self):

alert = Alert.objects.get(pk=alert.pk)
self.assertTrue(alert.solved)

def test_tag_list_is_slug(self):
tag = TagFactory(title="Test Slug")
result = self.client.get(reverse("opinion:list"), {"tag": tag.slug})
self.assertEqual(result.status_code, 200)
2 changes: 1 addition & 1 deletion zds/tutorialv2/views/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_queryset(self):
queryset = queryset.filter(content__subcategory__in=[self.subcategory])

if "tag" in self.request.GET:
self.tag = get_object_or_404(Tag, title=self.request.GET.get("tag").lower().strip())
self.tag = get_object_or_404(Tag, slug=slugify(self.request.GET.get("tag").lower().strip()))
# TODO: fix me
# different tags can have same slug such as C/C#/C++, as a first version we get all of them
queryset = queryset.filter(content__tags__in=[self.tag])
Expand Down

0 comments on commit d861945

Please sign in to comment.