Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use path instead of re_path for forum urls #1877

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use path instead of re_path for forum urls
Forum names are already slugs, this allows us to check against bad
queries at the URL stage not when getting the Forum object
alastair committed Mar 14, 2025
commit 76db6664ad593146101a6f39f5b5d1ca253eac5d
16 changes: 8 additions & 8 deletions forum/urls.py
Original file line number Diff line number Diff line change
@@ -27,14 +27,14 @@
path('moderate/', forum_views.moderate_posts, name="forums-moderate"),
path('forums-search/', search_views.search_forum, name="forums-search"),
path('hot-treads/', forum_views.hot_threads, name="forums-hot-threads"),
re_path(r'^(?P<forum_name_slug>[\w\-]+)/$', forum_views.forum, name="forums-forum"),
re_path(r'^(?P<forum_name_slug>[\w\-]+)/new-thread/$', forum_views.new_thread, name="forums-new-thread"),
re_path(r'^(?P<forum_name_slug>[\w-]+)/(?P<thread_id>\d+)/$', forum_views.thread, name="forums-thread"),
re_path(r'^(?P<forum_name_slug>[\w-]+)/(?P<thread_id>\d+)/unsubscribe/$', forum_views.unsubscribe_from_thread, name="forums-thread-unsubscribe"),
re_path(r'^(?P<forum_name_slug>[\w-]+)/(?P<thread_id>\d+)/subscribe/$', forum_views.subscribe_to_thread, name="forums-thread-subscribe"),
re_path(r'^(?P<forum_name_slug>[\w-]+)/(?P<thread_id>\d+)/(?P<post_id>\d+)/$', forum_views.post, name="forums-post"),
re_path(r'^(?P<forum_name_slug>[\w-]+)/(?P<thread_id>\d+)/reply/$', forum_views.reply, name="forums-reply"),
re_path(r'^(?P<forum_name_slug>[\w-]+)/(?P<thread_id>\d+)/(?P<post_id>\d+)/reply/$', forum_views.reply, name="forums-reply-quote"),
path('<slug:forum_name_slug>/', forum_views.forum, name="forums-forum"),
path('<slug:forum_name_slug>/new-thread/', forum_views.new_thread, name="forums-new-thread"),
path('<slug:forum_name_slug>/<int:thread_id>/', forum_views.thread, name="forums-thread"),
path('<slug:forum_name_slug>/<int:thread_id>/unsubscribe/', forum_views.unsubscribe_from_thread, name="forums-thread-unsubscribe"),
path('<slug:forum_name_slug>/<int:thread_id>/subscribe/', forum_views.subscribe_to_thread, name="forums-thread-subscribe"),
path('<slug:forum_name_slug>/<int:thread_id>/<int:post_id>/', forum_views.post, name="forums-post"),
path('<slug:forum_name_slug>/<int:thread_id>/reply/', forum_views.reply, name="forums-reply"),
path('<slug:forum_name_slug>/<int:thread_id>/<int:post_id>/reply/', forum_views.reply, name="forums-reply-quote"),

path('post/<int:post_id>/edit/', forum_views.post_edit, name="forums-post-edit"),
path('post/<int:post_id>/delete-confirm/', forum_views.post_delete_confirm, name="forums-post-delete-confirm"),