Skip to content

Commit

Permalink
[Main Nav] Fix blog topics url (#12286)
Browse files Browse the repository at this point in the history
* Reproduce bug

* Fix blog dropdown topics urls
  • Loading branch information
jhonatan-lopes authored Apr 30, 2024
1 parent 4785b77 commit d0c95f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion network-api/networkapi/nav/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def localized_featured_blog_topics(self):
blog_index_page = self.blog_index_page
for relationship in featured_topics_relationships:
if relationship.topic:
relationship.topic.url = blog_index_page.reverse_subpage(
relationship.topic.url = blog_index_page.url + blog_index_page.reverse_subpage(
"entries_by_topic", args=[relationship.topic.slug]
)

Expand Down
5 changes: 5 additions & 0 deletions network-api/networkapi/nav/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def setUp(self):
self.synchronize_tree()

def test_localized_featured_topics(self) -> None:
self.blog_index_page.slug = "blog"
self.blog_index_page.save_revision().publish()
# Create some topics:
topic_a = blog_factories.BlogPageTopicFactory(locale=self.default_locale, name="Topic A")
topic_b = blog_factories.BlogPageTopicFactory(locale=self.default_locale, name="Topic B")
Expand Down Expand Up @@ -80,6 +82,9 @@ def test_localized_featured_topics(self) -> None:
# It keeps the order:
self.assertEqual(topics[0], topic_b)
self.assertEqual(topics[1], topic_a)
# It adds the proper URL to the topics:
self.assertEqual(topics[0].url, "/en/blog/topic/topic-b/")
self.assertEqual(topics[1].url, "/en/blog/topic/topic-a/")

def test_number_of_queries_for_localized_featured_topics(self) -> None:
# Create some topics:
Expand Down

0 comments on commit d0c95f9

Please sign in to comment.