Skip to content

Commit

Permalink
feat(settings): make better urls
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Jul 6, 2023
1 parent 8b39aa9 commit 5c0398f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lacommunaute/forum/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

urlpatterns = [
path("forum/<str:slug>-<int:pk>/", ForumView.as_view(), name="forum"),
path("forum/documentation/", CategoryForumListView.as_view(), name="documentation"),
path("forum/", IndexView.as_view(), name="index"),
path("forums/", IndexView.as_view(), name="index"),
path("documentation/", CategoryForumListView.as_view(), name="documentation"),
]
8 changes: 3 additions & 5 deletions lacommunaute/forum_conversation/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def test_numqueries(self):
class TopicListViewTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.url = reverse("forum_conversation_extension:publicforum")
cls.url = reverse("forum_conversation_extension:topics")
cls.forum = ForumFactory(with_public_perms=True)
cls.topic = TopicFactory(with_post=True, with_like=True, forum=cls.forum)
cls.user = cls.topic.poster
Expand All @@ -499,9 +499,7 @@ def test_context(self):

self.assertIsInstance(response.context_data["form"], PostForm)
self.assertEqual(response.context_data["filters"], Filters.choices)
self.assertEqual(
response.context_data["loadmoretopic_url"], reverse("forum_conversation_extension:publicforum")
)
self.assertEqual(response.context_data["loadmoretopic_url"], reverse("forum_conversation_extension:topics"))
self.assertEqual(response.context_data["forum"], self.forum)
self.assertEqual(response.context_data["active_filter_name"], Filters.ALL.label)

Expand All @@ -510,7 +508,7 @@ def test_context(self):
response = self.client.get(self.url + f"?filter={filter}")
self.assertEqual(
response.context_data["loadmoretopic_url"],
reverse("forum_conversation_extension:publicforum") + f"?filter={filter}",
reverse("forum_conversation_extension:topics") + f"?filter={filter}",
)
self.assertEqual(response.context_data["active_filter_name"], label)

Expand Down
4 changes: 2 additions & 2 deletions lacommunaute/forum_conversation/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@


urlpatterns = [
path("publicforum/", TopicListView.as_view(), name="publicforum"),
path("newsfeed/", NewsFeedTopicListView.as_view(), name="newsfeed"),
path("topics/", TopicListView.as_view(), name="topics"),
path("news/", NewsFeedTopicListView.as_view(), name="newsfeed"),
path(
"forum/<str:forum_slug>-<int:forum_pk>/",
include(conversation_urlpatterns),
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/forum_conversation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_queryset(self):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["form"] = PostForm(user=self.request.user)
context["loadmoretopic_url"] = reverse("forum_conversation_extension:publicforum")
context["loadmoretopic_url"] = reverse("forum_conversation_extension:topics")

if self.get_filter():
context["loadmoretopic_url"] += f"?filter={self.get_filter()}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<button id="filtertopics-button"
hx-target="#topicsarea"
hx-swap="outerHTML"
hx-get="{% url 'forum_conversation_extension:publicforum' %}?filter={{ filter.0 }}"
hx-get="{% url 'forum_conversation_extension:topics' %}?filter={{ filter.0 }}"
class="dropdown-item matomo-event"
data-matomo-category="engagement"
data-matomo-action="filter"
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/templates/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<strong>Accès rapides</strong>
<ul>
<li>
<a href="{% url 'forum_conversation_extension:publicforum' %}">
<a href="{% url 'forum_conversation_extension:topics' %}">
Espace d'échanges
</a>
</li>
Expand Down
27 changes: 18 additions & 9 deletions lacommunaute/templates/partials/header_nav_secondary_items.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
{% load forum_member_tags %}
{% load i18n %}
{% load theme_inclusion %}


{% url 'pages:home' as home_url %}
{% url 'forum_conversation_extension:topics' as publicforum_url %}
{% url 'forum_conversation_extension:newsfeed' as newsfeed_url %}
{% url 'forum_extension:documentation' as documentation_url %}
{% url 'event:calendar' as calendar_url %}
{% url 'forum_search_extension:search' as search_url %}

<ul>
<li class="col-12 col-lg-auto">
<a href="{% url 'pages:home' %}" class="{% if request.path == '/' %}is-active{% endif %}">
<a href="{{ home_url }}" class="{% if request.path == home_url %}is-active{% endif %}">
Accueil
</a>
</li>
<li class="col-12 col-lg-auto">
<a href="{% url 'forum_conversation_extension:publicforum' %}" class="{% if request.path == '/publicforum/' %}is-active{% endif %}">
Espace d'échanges
<a href="{{ publicforum_url }}" class="{% if request.path == publicforum_url %}is-active{% endif %}">
{% trans "Discussion area" %}
</a>
</li>
<li>
<a href="{% url 'forum_conversation_extension:newsfeed' %}" class="{% if request.path == '/newsfeed/' %}is-active{% endif %}">
<a href="{{ newsfeed_url }}" class="{% if request.path == newsfeed_url %}is-active{% endif %}">
Actualités
</a>
</li>
<li>
<a href="{% url 'forum_extension:documentation' %}" class="{% if request.path == '/documentation/' %}is-active{% endif %}">
Documentations
<a href="{{ documentation_url }}" class="{% if request.path == documentation_url %}is-active{% endif %}">
{% trans "Documents" %}
</a>
</li>
<li>
<a href="{% url 'event:calendar' %}" class="{% if request.path == '/calendar/' %}is-active{% endif %}">
Évènements publics
<a href="{{ calendar_url }}" class="{% if request.path == calendar_url %}is-active{% endif %}">
{% trans "Events" %}
</a>
</li>
<li>
<a href="{% url 'forum_search_extension:search' %}" class="{% if request.path == '/search/' %}is-active{% endif %}">
<a href="{{ search_url }}" class="{% if request.path == search_url %}is-active{% endif %}">
{% trans "Search forums" %}
</a>
</li>
Expand Down

0 comments on commit 5c0398f

Please sign in to comment.