From 373d86e4e7f4c14db05ceebcad819d54a25214e2 Mon Sep 17 00:00:00 2001 From: Tasos Katsoulas Date: Wed, 31 Jul 2024 13:53:23 +0300 Subject: [PATCH] Display tags for all products in AAQ * More robust topic navigation check --- .../products/jinja2/products/documents.html | 1 - .../jinja2/questions/question_list.html | 4 +-- kitsune/questions/tests/test_templates.py | 28 +++++++++---------- kitsune/questions/views.py | 8 ++++-- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/kitsune/products/jinja2/products/documents.html b/kitsune/products/jinja2/products/documents.html index 33659fd38..418185a57 100644 --- a/kitsune/products/jinja2/products/documents.html +++ b/kitsune/products/jinja2/products/documents.html @@ -45,7 +45,6 @@ {{ topic_sidebar(topics[:10], subtopics, product, topic, subtopic) }} {% endif %} - {{ aaq_widget(request, "topic", topic) }} {% endblock %} diff --git a/kitsune/questions/jinja2/questions/question_list.html b/kitsune/questions/jinja2/questions/question_list.html index 3ef97d5f7..5f3c6dd9c 100644 --- a/kitsune/questions/jinja2/questions/question_list.html +++ b/kitsune/questions/jinja2/questions/question_list.html @@ -219,8 +219,8 @@ {% if question.topic %} {% set topic = question.topic %}
  • - - {{ pgettext('DB: products.Product.title', topic.product.title) }} + + {{ pgettext('DB: products.Product.title', question.product.title) }}
  • {% endif %} diff --git a/kitsune/questions/tests/test_templates.py b/kitsune/questions/tests/test_templates.py index d723b44ea..54ee2601e 100644 --- a/kitsune/questions/tests/test_templates.py +++ b/kitsune/questions/tests/test_templates.py @@ -17,13 +17,7 @@ from kitsune.questions.models import Answer, Question, QuestionLocale, VoteMetad from kitsune.questions.tests import AnswerFactory, QuestionFactory, tags_eq from kitsune.questions.views import NO_TAG, UNAPPROVED_TAG from kitsune.sumo.templatetags.jinja_helpers import urlparams -from kitsune.sumo.tests import ( - TestCase, - attrs_eq, - emailmessage_raise_smtp, - get, - post, -) +from kitsune.sumo.tests import TestCase, attrs_eq, emailmessage_raise_smtp, get, post from kitsune.sumo.urlresolvers import reverse from kitsune.tags.tests import TagFactory from kitsune.tidings.models import Watch @@ -1126,13 +1120,16 @@ class QuestionsTemplateTestCase(TestCase): def test_topic_filter(self): p = ProductFactory() - t1 = TopicFactory(product=p) - t2 = TopicFactory(product=p) - t3 = TopicFactory(product=p) + t1 = TopicFactory() + t2 = TopicFactory() + t3 = TopicFactory() + t1.products.add(p) + t2.products.add(p) + t3.products.add(p) - q1 = QuestionFactory() - q2 = QuestionFactory(topic=t1) - q3 = QuestionFactory(topic=t2) + q1 = QuestionFactory(product=p) + q2 = QuestionFactory(topic=t1, product=p) + q3 = QuestionFactory(topic=t2, product=p) url = reverse("questions.list", args=["all"]) @@ -1206,8 +1203,9 @@ class QuestionsTemplateTestCase(TestCase): def test_product_shows_without_tags(self): p = ProductFactory() - t = TopicFactory(product=p) - q = QuestionFactory(topic=t) + t = TopicFactory() + t.products.add(p) + q = QuestionFactory(topic=t, product=p) response = self.client.get(urlparams(reverse("questions.list", args=["all"]), show="")) doc = pq(response.content) diff --git a/kitsune/questions/views.py b/kitsune/questions/views.py index d1034e6d5..159dfb5f4 100644 --- a/kitsune/questions/views.py +++ b/kitsune/questions/views.py @@ -125,6 +125,12 @@ def question_list(request, product_slug=None, topic_slug=None): messages.add_message(request, messages.WARNING, "You cannot list questions at this time.") return HttpResponseRedirect("/") + topic_navigation = any( + [ + request.resolver_match.url_name == "questions.list_by_topic", + topic_slug and not product_slug, + ] + ) filter_ = request.GET.get("filter") owner = request.GET.get("owner", request.session.get("questions_owner", "all")) show = request.GET.get("show") @@ -157,7 +163,6 @@ def question_list(request, product_slug=None, topic_slug=None): # Get all topics topics = [] - topic_navigation = False if topic_slug: try: topic_history = TopicSlugHistory.objects.get(slug=topic_slug) @@ -166,7 +171,6 @@ def question_list(request, product_slug=None, topic_slug=None): except TopicSlugHistory.DoesNotExist: ... topics = Topic.active.filter(visible=True, slug=topic_slug) - topic_navigation = True if not topics: raise Http404()