diff --git a/network-api/networkapi/nav/models.py b/network-api/networkapi/nav/models.py index 6426e1cd090..bb47dc8dc4b 100644 --- a/network-api/networkapi/nav/models.py +++ b/network-api/networkapi/nav/models.py @@ -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] ) diff --git a/network-api/networkapi/nav/tests/test_models.py b/network-api/networkapi/nav/tests/test_models.py index 32290cbda92..01a9908dcaa 100644 --- a/network-api/networkapi/nav/tests/test_models.py +++ b/network-api/networkapi/nav/tests/test_models.py @@ -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") @@ -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: