From 99827e005b20bc43e94da447e2824ed690462887 Mon Sep 17 00:00:00 2001 From: thomas girod <56346771+imperosol@users.noreply.github.com> Date: Mon, 9 Jan 2023 22:07:03 +0100 Subject: [PATCH] upgrade re_path to path (#533) --- accounting/urls.py | 112 +++++++++++++------------- club/urls.py | 86 +++++++++----------- com/urls.py | 98 +++++++++++------------ core/converters.py | 35 +++++++++ core/tests.py | 63 ++++++++------- core/urls.py | 181 +++++++++++++++++++++---------------------- core/views/user.py | 18 ++--- counter/urls.py | 106 ++++++++++++------------- election/urls.py | 54 ++++++------- forum/urls.py | 63 +++++++-------- launderette/urls.py | 44 +++++------ matmat/urls.py | 10 +-- pedagogy/tests.py | 6 +- pedagogy/urls.py | 26 +++---- rootplace/urls.py | 10 +-- sas/urls.py | 36 ++++----- stock/urls.py | 52 ++++++------- subscription/urls.py | 6 +- trombi/urls.py | 58 +++++++------- 19 files changed, 528 insertions(+), 536 deletions(-) create mode 100644 core/converters.py diff --git a/accounting/urls.py b/accounting/urls.py index 70eeb158..4ae59a1e 100644 --- a/accounting/urls.py +++ b/accounting/urls.py @@ -22,133 +22,127 @@ # # -from django.urls import re_path +from django.urls import path from accounting.views import * urlpatterns = [ # Accounting types - re_path( - r"^simple_type$", + path( + "simple_type/", SimplifiedAccountingTypeListView.as_view(), name="simple_type_list", ), - re_path( - r"^simple_type/create$", + path( + "simple_type/create/", SimplifiedAccountingTypeCreateView.as_view(), name="simple_type_new", ), - re_path( - r"^simple_type/(?P[0-9]+)/edit$", + path( + "simple_type//edit/", SimplifiedAccountingTypeEditView.as_view(), name="simple_type_edit", ), # Accounting types - re_path(r"^type$", AccountingTypeListView.as_view(), name="type_list"), - re_path(r"^type/create$", AccountingTypeCreateView.as_view(), name="type_new"), - re_path( - r"^type/(?P[0-9]+)/edit$", + path("type/", AccountingTypeListView.as_view(), name="type_list"), + path("type/create/", AccountingTypeCreateView.as_view(), name="type_new"), + path( + "type//edit/", AccountingTypeEditView.as_view(), name="type_edit", ), # Bank accounts - re_path(r"^$", BankAccountListView.as_view(), name="bank_list"), - re_path(r"^bank/create$", BankAccountCreateView.as_view(), name="bank_new"), - re_path( - r"^bank/(?P[0-9]+)$", + path("", BankAccountListView.as_view(), name="bank_list"), + path("bank/create", BankAccountCreateView.as_view(), name="bank_new"), + path( + "bank//", BankAccountDetailView.as_view(), name="bank_details", ), - re_path( - r"^bank/(?P[0-9]+)/edit$", + path( + "bank//edit/", BankAccountEditView.as_view(), name="bank_edit", ), - re_path( - r"^bank/(?P[0-9]+)/delete$", + path( + "bank//delete/", BankAccountDeleteView.as_view(), name="bank_delete", ), # Club accounts - re_path(r"^club/create$", ClubAccountCreateView.as_view(), name="club_new"), - re_path( - r"^club/(?P[0-9]+)$", + path("club/create/", ClubAccountCreateView.as_view(), name="club_new"), + path( + "club//", ClubAccountDetailView.as_view(), name="club_details", ), - re_path( - r"^club/(?P[0-9]+)/edit$", + path( + "club//edit/", ClubAccountEditView.as_view(), name="club_edit", ), - re_path( - r"^club/(?P[0-9]+)/delete$", + path( + "club//delete/", ClubAccountDeleteView.as_view(), name="club_delete", ), # Journals - re_path(r"^journal/create$", JournalCreateView.as_view(), name="journal_new"), - re_path( - r"^journal/(?P[0-9]+)$", + path("journal/create/", JournalCreateView.as_view(), name="journal_new"), + path( + "journal//", JournalDetailView.as_view(), name="journal_details", ), - re_path( - r"^journal/(?P[0-9]+)/edit$", + path( + "journal//edit/", JournalEditView.as_view(), name="journal_edit", ), - re_path( - r"^journal/(?P[0-9]+)/delete$", + path( + "journal//delete/", JournalDeleteView.as_view(), name="journal_delete", ), - re_path( - r"^journal/(?P[0-9]+)/statement/nature$", + path( + "journal//statement/nature/", JournalNatureStatementView.as_view(), name="journal_nature_statement", ), - re_path( - r"^journal/(?P[0-9]+)/statement/person$", + path( + "journal//statement/person/", JournalPersonStatementView.as_view(), name="journal_person_statement", ), - re_path( - r"^journal/(?P[0-9]+)/statement/accounting$", + path( + "journal//statement/accounting/", JournalAccountingStatementView.as_view(), name="journal_accounting_statement", ), # Operations - re_path( - r"^operation/create/(?P[0-9]+)$", + path( + "operation/create//", OperationCreateView.as_view(), name="op_new", ), - re_path( - r"^operation/(?P[0-9]+)$", OperationEditView.as_view(), name="op_edit" - ), - re_path( - r"^operation/(?P[0-9]+)/pdf$", OperationPDFView.as_view(), name="op_pdf" - ), + path("operation//", OperationEditView.as_view(), name="op_edit"), + path("operation//pdf/", OperationPDFView.as_view(), name="op_pdf"), # Companies - re_path(r"^company/list$", CompanyListView.as_view(), name="co_list"), - re_path(r"^company/create$", CompanyCreateView.as_view(), name="co_new"), - re_path(r"^company/(?P[0-9]+)$", CompanyEditView.as_view(), name="co_edit"), + path("company/list/", CompanyListView.as_view(), name="co_list"), + path("company/create/", CompanyCreateView.as_view(), name="co_new"), + path("company//", CompanyEditView.as_view(), name="co_edit"), # Labels - re_path(r"^label/new$", LabelCreateView.as_view(), name="label_new"), - re_path( - r"^label/(?P[0-9]+)$", + path("label/new/", LabelCreateView.as_view(), name="label_new"), + path( + "label//", LabelListView.as_view(), name="label_list", ), - re_path( - r"^label/(?P[0-9]+)/edit$", LabelEditView.as_view(), name="label_edit" - ), - re_path( - r"^label/(?P[0-9]+)/delete$", + path("label//edit/", LabelEditView.as_view(), name="label_edit"), + path( + "label//delete/", LabelDeleteView.as_view(), name="label_delete", ), # User account - re_path(r"^refound/account$", RefoundAccountView.as_view(), name="refound_account"), + path("refound/account/", RefoundAccountView.as_view(), name="refound_account"), ] diff --git a/club/urls.py b/club/urls.py index ed08472f..d33a5167 100644 --- a/club/urls.py +++ b/club/urls.py @@ -23,94 +23,84 @@ # # -from django.urls import re_path +from django.urls import path from club.views import * urlpatterns = [ - re_path(r"^$", ClubListView.as_view(), name="club_list"), - re_path(r"^new$", ClubCreateView.as_view(), name="club_new"), - re_path(r"^stats$", ClubStatView.as_view(), name="club_stats"), - re_path(r"^(?P[0-9]+)/$", ClubView.as_view(), name="club_view"), - re_path( - r"^(?P[0-9]+)/rev/(?P[0-9]+)/$", + path("", ClubListView.as_view(), name="club_list"), + path("new/", ClubCreateView.as_view(), name="club_new"), + path("stats/", ClubStatView.as_view(), name="club_stats"), + path("/", ClubView.as_view(), name="club_view"), + path( + "/rev//", ClubRevView.as_view(), name="club_view_rev", ), - re_path( - r"^(?P[0-9]+)/hist$", ClubPageHistView.as_view(), name="club_hist" - ), - re_path(r"^(?P[0-9]+)/edit$", ClubEditView.as_view(), name="club_edit"), - re_path( - r"^(?P[0-9]+)/edit/page$", + path("/hist/", ClubPageHistView.as_view(), name="club_hist"), + path("/edit/", ClubEditView.as_view(), name="club_edit"), + path( + "/edit/page/", ClubPageEditView.as_view(), name="club_edit_page", ), - re_path( - r"^(?P[0-9]+)/members$", ClubMembersView.as_view(), name="club_members" - ), - re_path( - r"^(?P[0-9]+)/elderlies$", + path("/members/", ClubMembersView.as_view(), name="club_members"), + path( + "/elderlies/", ClubOldMembersView.as_view(), name="club_old_members", ), - re_path( - r"^(?P[0-9]+)/sellings$", + path( + "/sellings/", ClubSellingView.as_view(), name="club_sellings", ), - re_path( - r"^(?P[0-9]+)/sellings/csv$", + path( + "/sellings/csv/", ClubSellingCSVView.as_view(), name="sellings_csv", ), - re_path( - r"^(?P[0-9]+)/prop$", ClubEditPropView.as_view(), name="club_prop" - ), - re_path(r"^(?P[0-9]+)/tools$", ClubToolsView.as_view(), name="tools"), - re_path( - r"^(?P[0-9]+)/mailing$", ClubMailingView.as_view(), name="mailing" - ), - re_path( - r"^(?P[0-9]+)/mailing/generate$", + path("/prop/", ClubEditPropView.as_view(), name="club_prop"), + path("/tools/", ClubToolsView.as_view(), name="tools"), + path("/mailing/", ClubMailingView.as_view(), name="mailing"), + path( + "/mailing/generate/", MailingAutoGenerationView.as_view(), name="mailing_generate", ), - re_path( - r"^(?P[0-9]+)/mailing/delete$", + path( + "/mailing/delete/", MailingDeleteView.as_view(), name="mailing_delete", ), - re_path( - r"^(?P[0-9]+)/mailing/delete/subscription$", + path( + "/mailing/delete/subscription/", MailingSubscriptionDeleteView.as_view(), name="mailing_subscription_delete", ), - re_path( - r"^membership/(?P[0-9]+)/set_old$", + path( + "membership//set_old/", MembershipSetOldView.as_view(), name="membership_set_old", ), - re_path( - r"^membership/(?P[0-9]+)/delete$", + path( + "membership//delete/", MembershipDeleteView.as_view(), name="membership_delete", ), - re_path( - r"^(?P[0-9]+)/poster$", PosterListView.as_view(), name="poster_list" - ), - re_path( - r"^(?P[0-9]+)/poster/create$", + path("/poster/", PosterListView.as_view(), name="poster_list"), + path( + "/poster/create/", PosterCreateView.as_view(), name="poster_create", ), - re_path( - r"^(?P[0-9]+)/poster/(?P[0-9]+)/edit$", + path( + "/poster//edit/", PosterEditView.as_view(), name="poster_edit", ), - re_path( - r"^(?P[0-9]+)/poster/(?P[0-9]+)/delete$", + path( + "/poster//delete/", PosterDeleteView.as_view(), name="poster_delete", ), diff --git a/com/urls.py b/com/urls.py index 6128d1d4..433ec3b3 100644 --- a/com/urls.py +++ b/com/urls.py @@ -22,104 +22,98 @@ # # -from django.urls import re_path +from django.urls import path -from com.views import * from club.views import MailingDeleteView +from com.views import * urlpatterns = [ - re_path(r"^sith/edit/alert$", AlertMsgEditView.as_view(), name="alert_edit"), - re_path(r"^sith/edit/info$", InfoMsgEditView.as_view(), name="info_edit"), - re_path( - r"^sith/edit/weekmail_destinations$", + path("sith/edit/alert/", AlertMsgEditView.as_view(), name="alert_edit"), + path("sith/edit/info/", InfoMsgEditView.as_view(), name="info_edit"), + path( + "sith/edit/weekmail_destinations/", WeekmailDestinationEditView.as_view(), name="weekmail_destinations", ), - re_path(r"^weekmail$", WeekmailEditView.as_view(), name="weekmail"), - re_path( - r"^weekmail/preview$", WeekmailPreviewView.as_view(), name="weekmail_preview" - ), - re_path( - r"^weekmail/new_article$", + path("weekmail/", WeekmailEditView.as_view(), name="weekmail"), + path("weekmail/preview/", WeekmailPreviewView.as_view(), name="weekmail_preview"), + path( + "weekmail/new_article/", WeekmailArticleCreateView.as_view(), name="weekmail_article", ), - re_path( - r"^weekmail/article/(?P[0-9]+)/delete$", + path( + "weekmail/article//delete/", WeekmailArticleDeleteView.as_view(), name="weekmail_article_delete", ), - re_path( - r"^weekmail/article/(?P[0-9]+)/edit$", + path( + "weekmail/article//edit/", WeekmailArticleEditView.as_view(), name="weekmail_article_edit", ), - re_path(r"^news$", NewsListView.as_view(), name="news_list"), - re_path(r"^news/admin$", NewsAdminListView.as_view(), name="news_admin_list"), - re_path(r"^news/create$", NewsCreateView.as_view(), name="news_new"), - re_path( - r"^news/(?P[0-9]+)/delete$", + path("news/", NewsListView.as_view(), name="news_list"), + path("news/admin/", NewsAdminListView.as_view(), name="news_admin_list"), + path("news/create/", NewsCreateView.as_view(), name="news_new"), + path( + "news//delete/", NewsDeleteView.as_view(), name="news_delete", ), - re_path( - r"^news/(?P[0-9]+)/moderate$", + path( + "news//moderate/", NewsModerateView.as_view(), name="news_moderate", ), - re_path( - r"^news/(?P[0-9]+)/edit$", NewsEditView.as_view(), name="news_edit" - ), - re_path( - r"^news/(?P[0-9]+)$", NewsDetailView.as_view(), name="news_detail" - ), - re_path(r"^mailings$", MailingListAdminView.as_view(), name="mailing_admin"), - re_path( - r"^mailings/(?P[0-9]+)/moderate$", + path("news//edit/", NewsEditView.as_view(), name="news_edit"), + path("news//", NewsDetailView.as_view(), name="news_detail"), + path("mailings/", MailingListAdminView.as_view(), name="mailing_admin"), + path( + "mailings//moderate/", MailingModerateView.as_view(), name="mailing_moderate", ), - re_path( - r"^mailings/(?P[0-9]+)/delete$", + path( + "mailings//delete/", MailingDeleteView.as_view(redirect_page="com:mailing_admin"), name="mailing_delete", ), - re_path(r"^poster$", PosterListView.as_view(), name="poster_list"), - re_path(r"^poster/create$", PosterCreateView.as_view(), name="poster_create"), - re_path( - r"^poster/(?P[0-9]+)/edit$", + path("poster/", PosterListView.as_view(), name="poster_list"), + path("poster/create/", PosterCreateView.as_view(), name="poster_create"), + path( + "poster//edit/", PosterEditView.as_view(), name="poster_edit", ), - re_path( - r"^poster/(?P[0-9]+)/delete$", + path( + "poster//delete/", PosterDeleteView.as_view(), name="poster_delete", ), - re_path( - r"^poster/moderate$", + path( + "poster/moderate/", PosterModerateListView.as_view(), name="poster_moderate_list", ), - re_path( - r"^poster/(?P[0-9]+)/moderate$", + path( + "poster//moderate/", PosterModerateView.as_view(), name="poster_moderate", ), - re_path(r"^screen$", ScreenListView.as_view(), name="screen_list"), - re_path(r"^screen/create$", ScreenCreateView.as_view(), name="screen_create"), - re_path( - r"^screen/(?P[0-9]+)/slideshow$", + path("screen/", ScreenListView.as_view(), name="screen_list"), + path("screen/create/", ScreenCreateView.as_view(), name="screen_create"), + path( + "screen//slideshow/", ScreenSlideshowView.as_view(), name="screen_slideshow", ), - re_path( - r"^screen/(?P[0-9]+)/edit$", + path( + "screen//edit/", ScreenEditView.as_view(), name="screen_edit", ), - re_path( - r"^screen/(?P[0-9]+)/delete$", + path( + "screen//delete/", ScreenDeleteView.as_view(), name="screen_delete", ), diff --git a/core/converters.py b/core/converters.py new file mode 100644 index 00000000..cb7bc95b --- /dev/null +++ b/core/converters.py @@ -0,0 +1,35 @@ +from core.models import Page + + +class FourDigitYearConverter: + regex = "[0-9]{4}" + + def to_python(self, value): + return int(value) + + def to_url(self, value): + return str(value).zfill(4) + + +class TwoDigitMonthConverter: + regex = "[0-9]{2}" + + def to_python(self, value): + return int(value) + + def to_url(self, value): + return str(value).zfill(2) + + +class BooleanStringConverter: + """ + Converter whose regex match either True or False + """ + + regex = r"(True)|(False)" + + def to_python(self, value): + return str(value) == "True" + + def to_url(self, value): + return str(value) diff --git a/core/tests.py b/core/tests.py index d1ebd6af..ddb9f03d 100644 --- a/core/tests.py +++ b/core/tests.py @@ -290,33 +290,40 @@ class MarkdownTest(TestCase): class PageHandlingTest(TestCase): def setUp(self): - try: - Group.objects.create(name="root") - u = User( - username="root", - last_name="", - first_name="Bibou", - email="ae.info@utbm.fr", - date_of_birth="1942-06-12", - is_superuser=True, - is_staff=True, - ) - u.set_password("plop") - u.save() - self.client.login(username="root", password="plop") - except Exception as e: - print(e) + self.root_group = Group.objects.create(name="root") + u = User( + username="root", + last_name="", + first_name="Bibou", + email="ae.info@utbm.fr", + date_of_birth="1942-06-12", + is_superuser=True, + is_staff=True, + ) + u.set_password("plop") + u.save() + self.client.login(username="root", password="plop") def test_create_page_ok(self): """ Should create a page correctly """ - self.client.post( - reverse("core:page_new"), {"parent": "", "name": "guy", "owner_group": 1} + + response = self.client.post( + reverse("core:page_new"), + {"parent": "", "name": "guy", "owner_group": self.root_group.id}, ) + self.assertRedirects( + response, reverse("core:page", kwargs={"page_name": "guy"}) + ) + self.assertTrue(Page.objects.filter(name="guy").exists()) + response = self.client.get(reverse("core:page", kwargs={"page_name": "guy"})) - self.assertTrue(response.status_code == 200) - self.assertTrue('' in str(response.content)) + self.assertEqual(response.status_code, 200) + html = response.content.decode() + self.assertIn('', html) + self.assertIn('', html) + self.assertIn('', html) def test_create_child_page_ok(self): """ @@ -339,29 +346,25 @@ class PageHandlingTest(TestCase): """ Should display a page correctly """ - parent = Page(name="guy", owner_group=Group.objects.filter(id=1).first()) + parent = Page(name="guy", owner_group=self.root_group) parent.save(force_lock=True) - page = Page( - name="bibou", owner_group=Group.objects.filter(id=1).first(), parent=parent - ) + page = Page(name="bibou", owner_group=self.root_group, parent=parent) page.save(force_lock=True) response = self.client.get( reverse("core:page", kwargs={"page_name": "guy/bibou"}) ) self.assertTrue(response.status_code == 200) - self.assertTrue( - '\\xc3\\x89diter' - in str(response.content) - ) + html = response.content.decode() + self.assertIn('', html) def test_access_page_not_found(self): """ Should not display a page correctly """ response = self.client.get(reverse("core:page", kwargs={"page_name": "swagg"})) - response = self.client.get("/page/swagg/") self.assertTrue(response.status_code == 200) - self.assertTrue('' in str(response.content)) + html = response.content.decode() + self.assertIn('', html) def test_create_page_markdown_safe(self): """ diff --git a/core/urls.py b/core/urls.py index 1c2577fc..ec42f880 100644 --- a/core/urls.py +++ b/core/urls.py @@ -23,40 +23,46 @@ # # -from django.urls import re_path, path +from django.urls import path, re_path, register_converter from core.views import * +from core.converters import ( + FourDigitYearConverter, + TwoDigitMonthConverter, + BooleanStringConverter, +) + +register_converter(FourDigitYearConverter, "yyyy") +register_converter(TwoDigitMonthConverter, "mm") +register_converter(BooleanStringConverter, "bool") + urlpatterns = [ - re_path(r"^$", index, name="index"), - re_path(r"^to_markdown$", ToMarkdownView.as_view(), name="to_markdown"), - re_path(r"^notifications$", NotificationList.as_view(), name="notification_list"), - re_path(r"^notification/(?P[0-9]+)$", notification, name="notification"), + path("", index, name="index"), + path("to_markdown/", ToMarkdownView.as_view(), name="to_markdown"), + path("notifications/", NotificationList.as_view(), name="notification_list"), + path("notification//", notification, name="notification"), # Search - re_path(r"^search/$", search_view, name="search"), - re_path(r"^search_json/$", search_json, name="search_json"), - re_path(r"^search_user/$", search_user_json, name="search_user"), + path("search/", search_view, name="search"), + path("search_json/", search_json, name="search_json"), + path("search_user/", search_user_json, name="search_user"), # Login and co - re_path(r"^login/$", SithLoginView.as_view(), name="login"), - re_path(r"^logout/$", logout, name="logout"), - re_path( - r"^password_change/$", SithPasswordChangeView.as_view(), name="password_change" - ), - re_path( - r"^password_change/(?P[0-9]+)$", + path("login/", SithLoginView.as_view(), name="login"), + path("logout/", logout, name="logout"), + path("password_change/", SithPasswordChangeView.as_view(), name="password_change"), + path( + "password_change//", password_root_change, name="password_root_change", ), - re_path( - r"^password_change/done$", + path( + "password_change/done/", SithPasswordChangeDoneView.as_view(), name="password_change_done", ), - re_path( - r"^password_reset/$", SithPasswordResetView.as_view(), name="password_reset" - ), - re_path( - r"^password_reset/done$", + path("password_reset/", SithPasswordResetView.as_view(), name="password_reset"), + path( + "password_reset/done/", SithPasswordResetDoneView.as_view(), name="password_reset_done", ), @@ -65,110 +71,103 @@ urlpatterns = [ SithPasswordResetConfirmView.as_view(), name="password_reset_confirm", ), - re_path( - r"^reset/done/$", + path( + "reset/done/", SithPasswordResetCompleteView.as_view(), name="password_reset_complete", ), - re_path(r"^register$", register, name="register"), + path("register/", register, name="register"), # Group handling - re_path(r"^group/$", GroupListView.as_view(), name="group_list"), - re_path(r"^group/new/$", GroupCreateView.as_view(), name="group_new"), - re_path( - r"^group/(?P[0-9]+)/$", GroupEditView.as_view(), name="group_edit" - ), - re_path( - r"^group/(?P[0-9]+)/delete$", + path("group/", GroupListView.as_view(), name="group_list"), + path("group/new/", GroupCreateView.as_view(), name="group_new"), + path("group//", GroupEditView.as_view(), name="group_edit"), + path( + "group//delete/", GroupDeleteView.as_view(), name="group_delete", ), - re_path( - r"^group/(?P[0-9]+)/detail$", + path( + "group//detail/", GroupTemplateView.as_view(), name="group_detail", ), # User views - re_path(r"^user/$", UserListView.as_view(), name="user_list"), - re_path( - r"^user/(?P[0-9]+)/mini$", + path("user/", UserListView.as_view(), name="user_list"), + path( + "user//mini/", UserMiniView.as_view(), name="user_profile_mini", ), - re_path(r"^user/(?P[0-9]+)/$", UserView.as_view(), name="user_profile"), - re_path( - r"^user/(?P[0-9]+)/pictures$", + path("user//", UserView.as_view(), name="user_profile"), + path( + "user//pictures/", UserPicturesView.as_view(), name="user_pictures", ), - re_path( - r"^user/(?P[0-9]+)/godfathers$", + path( + "user//godfathers/", UserGodfathersView.as_view(), name="user_godfathers", ), - re_path( - r"^user/(?P[0-9]+)/godfathers/tree$", + path( + "user//godfathers/tree/", UserGodfathersTreeView.as_view(), name="user_godfathers_tree", ), - re_path( - r"^user/(?P[0-9]+)/godfathers/tree/pict$", + path( + "user//godfathers/tree/pict/", UserGodfathersTreePictureView.as_view(), name="user_godfathers_tree_pict", ), - re_path( - r"^user/(?P[0-9]+)/godfathers/(?P[0-9]+)/(?P(True)|(False))/delete$", - DeleteUserGodfathers, + path( + "user//godfathers///delete/", + delete_user_godfather, name="user_godfathers_delete", ), - re_path( - r"^user/(?P[0-9]+)/edit$", + path( + "user//edit/", UserUpdateProfileView.as_view(), name="user_edit", ), - re_path( - r"^user/(?P[0-9]+)/profile_upload$", + path( + "user//profile_upload/", UserUploadProfilePictView.as_view(), name="user_profile_upload", ), - re_path( - r"^user/(?P[0-9]+)/clubs$", UserClubView.as_view(), name="user_clubs" - ), - re_path( - r"^user/(?P[0-9]+)/prefs$", + path("user//clubs/", UserClubView.as_view(), name="user_clubs"), + path( + "user//prefs/", UserPreferencesView.as_view(), name="user_prefs", ), - re_path( - r"^user/(?P[0-9]+)/groups$", + path( + "user//groups/", UserUpdateGroupView.as_view(), name="user_groups", ), - re_path(r"^user/tools/$", UserToolsView.as_view(), name="user_tools"), - re_path( - r"^user/(?P[0-9]+)/account$", + path("user/tools/", UserToolsView.as_view(), name="user_tools"), + path( + "user//account/", UserAccountView.as_view(), name="user_account", ), - re_path( - r"^user/(?P[0-9]+)/account/(?P[0-9]+)/(?P[0-9]+)$", + path( + "user//account///", UserAccountDetailView.as_view(), name="user_account_detail", ), - re_path( - r"^user/(?P[0-9]+)/stats$", UserStatsView.as_view(), name="user_stats" - ), - re_path( - r"^user/(?P[0-9]+)/gift/create$", + path("user//stats/", UserStatsView.as_view(), name="user_stats"), + path( + "user//gift/create/", GiftCreateView.as_view(), name="user_gift_create", ), - re_path( - r"^user/(?P[0-9]+)/gift/delete/(?P[0-9]+)/$", + path( + "user//gift/delete//", GiftDeleteView.as_view(), name="user_gift_delete", ), # File views - # re_path(r'^file/add/(?Ppopup)?$', FileCreateView.as_view(), name='file_new'), re_path(r"^file/(?Ppopup)?$", FileListView.as_view(), name="file_list"), re_path( r"^file/(?P[0-9]+)/(?Ppopup)?$", @@ -190,43 +189,43 @@ urlpatterns = [ FileDeleteView.as_view(), name="file_delete", ), - re_path(r"^file/moderation$", FileModerationView.as_view(), name="file_moderation"), - re_path( - r"^file/(?P[0-9]+)/moderate$", + path("file/moderation/", FileModerationView.as_view(), name="file_moderation"), + path( + "file//moderate/", FileModerateView.as_view(), name="file_moderate", ), - re_path(r"^file/(?P[0-9]+)/download$", send_file, name="download"), + path("file//download/", send_file, name="download"), # Page views - re_path(r"^page/$", PageListView.as_view(), name="page_list"), - re_path(r"^page/create$", PageCreateView.as_view(), name="page_new"), - re_path( - r"^page/(?P[0-9]*)/delete$", + path("page/", PageListView.as_view(), name="page_list"), + path("page/create/", PageCreateView.as_view(), name="page_new"), + path( + "page//delete/", PageDeleteView.as_view(), name="page_delete", ), - re_path( - r"^page/(?P([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/edit$", + path( + "page//edit/", PageEditView.as_view(), name="page_edit", ), - re_path( - r"^page/(?P([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/prop$", + path( + "page//prop/", PagePropView.as_view(), name="page_prop", ), - re_path( - r"^page/(?P([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/hist$", + path( + "page//hist/", PageHistView.as_view(), name="page_hist", ), - re_path( - r"^page/(?P([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/rev/(?P[0-9]+)/", + path( + "page//rev//", PageRevView.as_view(), name="page_rev", ), - re_path( - r"^page/(?P([/a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])+)/$", + path( + "page//", PageView.as_view(), name="page", ), diff --git a/core/views/user.py b/core/views/user.py index 3dc6c28b..8a8a97cd 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -338,16 +338,16 @@ class UserPicturesView(UserTabsMixin, CanViewMixin, DetailView): return kwargs -def DeleteUserGodfathers(request, user_id, godfather_id, is_father): - user = User.objects.get(id=user_id) - if (user == request.user) or request.user.is_root or request.user.is_board_member: - ud = get_object_or_404(User, id=godfather_id) - if is_father == "True": - user.godfathers.remove(ud) - else: - user.godchildren.remove(ud) +def delete_user_godfather(request, user_id, godfather_id, is_father): + user_is_admin = request.user.is_root or request.user.is_board_member + if user_id != request.user.id and not user_is_admin: + raise PermissionDenied() + user = get_object_or_404(User, id=user_id) + to_remove = get_object_or_404(User, id=godfather_id) + if is_father: + user.godfathers.remove(to_remove) else: - raise PermissionDenied + user.godchildren.remove(to_remove) return redirect("core:user_godfathers", user_id=user_id) diff --git a/counter/urls.py b/counter/urls.py index 7195ddc6..449c0fe0 100644 --- a/counter/urls.py +++ b/counter/urls.py @@ -22,47 +22,47 @@ # # -from django.urls import re_path, path +from django.urls import path from counter.views import * urlpatterns = [ - re_path(r"^(?P[0-9]+)$", CounterMain.as_view(), name="details"), - re_path( - r"^(?P[0-9]+)/click/(?P[0-9]+)$", + path("/", CounterMain.as_view(), name="details"), + path( + "/click//", CounterClick.as_view(), name="click", ), - re_path( - r"^(?P[0-9]+)/last_ops$", + path( + "/last_ops/", CounterLastOperationsView.as_view(), name="last_ops", ), - re_path( - r"^(?P[0-9]+)/cash_summary$", + path( + "/cash_summary/", CounterCashSummaryView.as_view(), name="cash_summary", ), - re_path( - r"^(?P[0-9]+)/activity$", + path( + "/activity/", CounterActivityView.as_view(), name="activity", ), - re_path(r"^(?P[0-9]+)/stats$", CounterStatView.as_view(), name="stats"), - re_path(r"^(?P[0-9]+)/login$", CounterLogin.as_view(), name="login"), - re_path(r"^(?P[0-9]+)/logout$", CounterLogout.as_view(), name="logout"), - re_path( - r"^eticket/(?P[0-9]+)/pdf$", + path("/stats/", CounterStatView.as_view(), name="stats"), + path("/login/", CounterLogin.as_view(), name="login"), + path("/logout/", CounterLogout.as_view(), name="logout"), + path( + "eticket//pdf/", EticketPDFView.as_view(), name="eticket_pdf", ), - re_path( - r"^customer/(?P[0-9]+)/card/add$", + path( + "customer//card/add/", StudentCardFormView.as_view(), name="add_student_card", ), - re_path( - r"^customer/(?P[0-9]+)/card/delete/(?P[0-9]+)/$", + path( + "customer//card/delete//", StudentCardDeleteView.as_view(), name="delete_student_card", ), @@ -76,76 +76,76 @@ urlpatterns = [ edit_billing_info, name="edit_billing_info", ), - re_path(r"^admin/(?P[0-9]+)$", CounterEditView.as_view(), name="admin"), - re_path( - r"^admin/(?P[0-9]+)/prop$", + path("admin//", CounterEditView.as_view(), name="admin"), + path( + "admin//prop/", CounterEditPropView.as_view(), name="prop_admin", ), - re_path(r"^admin$", CounterListView.as_view(), name="admin_list"), - re_path(r"^admin/new$", CounterCreateView.as_view(), name="new"), - re_path( - r"^admin/delete/(?P[0-9]+)$", + path("admin/", CounterListView.as_view(), name="admin_list"), + path("admin/new/", CounterCreateView.as_view(), name="new"), + path( + "admin/delete//", CounterDeleteView.as_view(), name="delete", ), - re_path(r"^admin/invoices_call$", InvoiceCallView.as_view(), name="invoices_call"), - re_path( - r"^admin/cash_summary/list$", + path("admin/invoices_call/", InvoiceCallView.as_view(), name="invoices_call"), + path( + "admin/cash_summary/list/", CashSummaryListView.as_view(), name="cash_summary_list", ), - re_path( - r"^admin/cash_summary/(?P[0-9]+)$", + path( + "admin/cash_summary//", CashSummaryEditView.as_view(), name="cash_summary_edit", ), - re_path(r"^admin/product/list$", ProductListView.as_view(), name="product_list"), - re_path( - r"^admin/product/list_archived$", + path("admin/product/list/", ProductListView.as_view(), name="product_list"), + path( + "admin/product/list_archived/", ProductArchivedListView.as_view(), name="product_list_archived", ), - re_path(r"^admin/product/create$", ProductCreateView.as_view(), name="new_product"), - re_path( - r"^admin/product/(?P[0-9]+)$", + path("admin/product/create/", ProductCreateView.as_view(), name="new_product"), + path( + "admin/product//", ProductEditView.as_view(), name="product_edit", ), - re_path( - r"^admin/producttype/list$", + path( + "admin/producttype/list/", ProductTypeListView.as_view(), name="producttype_list", ), - re_path( - r"^admin/producttype/create$", + path( + "admin/producttype/create/", ProductTypeCreateView.as_view(), name="new_producttype", ), - re_path( - r"^admin/producttype/(?P[0-9]+)$", + path( + "admin/producttype//", ProductTypeEditView.as_view(), name="producttype_edit", ), - re_path(r"^admin/eticket/list$", EticketListView.as_view(), name="eticket_list"), - re_path(r"^admin/eticket/new$", EticketCreateView.as_view(), name="new_eticket"), - re_path( - r"^admin/eticket/(?P[0-9]+)$", + path("admin/eticket/list/", EticketListView.as_view(), name="eticket_list"), + path("admin/eticket/new/", EticketCreateView.as_view(), name="new_eticket"), + path( + "admin/eticket//", EticketEditView.as_view(), name="edit_eticket", ), - re_path( - r"^admin/selling/(?P[0-9]+)/delete$", + path( + "admin/selling//delete/", SellingDeleteView.as_view(), name="selling_delete", ), - re_path( - r"^admin/refilling/(?P[0-9]+)/delete$", + path( + "admin/refilling//delete/", RefillingDeleteView.as_view(), name="refilling_delete", ), - re_path( - r"^admin/(?P[0-9]+)/refillings$", + path( + "admin//refillings/", CounterRefillingListView.as_view(), name="refilling_list", ), diff --git a/election/urls.py b/election/urls.py index 4d6b4e1e..697b2464 100644 --- a/election/urls.py +++ b/election/urls.py @@ -1,57 +1,49 @@ -from django.urls import re_path +from django.urls import path from election.views import * urlpatterns = [ - re_path(r"^$", ElectionsListView.as_view(), name="list"), - re_path(r"^archived$", ElectionListArchivedView.as_view(), name="list_archived"), - re_path(r"^add$", ElectionCreateView.as_view(), name="create"), - re_path( - r"^(?P[0-9]+)/edit$", ElectionUpdateView.as_view(), name="update" - ), - re_path( - r"^(?P[0-9]+)/delete$", ElectionDeleteView.as_view(), name="delete" - ), - re_path( - r"^(?P[0-9]+)/list/add$", + path("", ElectionsListView.as_view(), name="list"), + path("archived/", ElectionListArchivedView.as_view(), name="list_archived"), + path("add/", ElectionCreateView.as_view(), name="create"), + path("/edit/", ElectionUpdateView.as_view(), name="update"), + path("/delete/", ElectionDeleteView.as_view(), name="delete"), + path( + "/list/add/", ElectionListCreateView.as_view(), name="create_list", ), - re_path( - r"^(?P[0-9]+)/list/delete$", + path( + "/list/delete/", ElectionListDeleteView.as_view(), name="delete_list", ), - re_path( - r"^(?P[0-9]+)/role/create$", + path( + "/role/create/", RoleCreateView.as_view(), name="create_role", ), - re_path( - r"^(?P[0-9]+)/role/edit$", RoleUpdateView.as_view(), name="update_role" - ), - re_path( - r"^(?P[0-9]+)/role/delete$", + path("/role/edit/", RoleUpdateView.as_view(), name="update_role"), + path( + "/role/delete/", RoleDeleteView.as_view(), name="delete_role", ), - re_path( - r"^(?P[0-9]+)/candidate/add$", + path( + "/candidate/add/", CandidatureCreateView.as_view(), name="candidate", ), - re_path( - r"^(?P[0-9]+)/candidate/edit$", + path( + "/candidate/edit/", CandidatureUpdateView.as_view(), name="update_candidate", ), - re_path( - r"^(?P[0-9]+)/candidate/delete$", + path( + "/candidate/delete/", CandidatureDeleteView.as_view(), name="delete_candidate", ), - re_path(r"^(?P[0-9]+)/vote$", VoteFormView.as_view(), name="vote"), - re_path( - r"^(?P[0-9]+)/detail$", ElectionDetailView.as_view(), name="detail" - ), + path("/vote/", VoteFormView.as_view(), name="vote"), + path("/detail/", ElectionDetailView.as_view(), name="detail"), ] diff --git a/forum/urls.py b/forum/urls.py index de19d7cc..8926ea01 100644 --- a/forum/urls.py +++ b/forum/urls.py @@ -22,69 +22,62 @@ # # -from django.urls import re_path +from django.urls import path from forum.views import * - urlpatterns = [ - re_path(r"^$", ForumMainView.as_view(), name="main"), - re_path(r"^search/$", ForumSearchView.as_view(), name="search"), - re_path(r"^new_forum$", ForumCreateView.as_view(), name="new_forum"), - re_path( - r"^mark_all_as_read$", ForumMarkAllAsRead.as_view(), name="mark_all_as_read" - ), - re_path(r"^last_unread$", ForumLastUnread.as_view(), name="last_unread"), - re_path( - r"^favorite_topics$", ForumFavoriteTopics.as_view(), name="favorite_topics" - ), - re_path(r"^(?P[0-9]+)$", ForumDetailView.as_view(), name="view_forum"), - re_path(r"^(?P[0-9]+)/edit$", ForumEditView.as_view(), name="edit_forum"), - re_path( - r"^(?P[0-9]+)/delete$", ForumDeleteView.as_view(), name="delete_forum" - ), - re_path( - r"^(?P[0-9]+)/new_topic$", + path("", ForumMainView.as_view(), name="main"), + path("search/", ForumSearchView.as_view(), name="search"), + path("new_forum/", ForumCreateView.as_view(), name="new_forum"), + path("mark_all_as_read/", ForumMarkAllAsRead.as_view(), name="mark_all_as_read"), + path("last_unread/", ForumLastUnread.as_view(), name="last_unread"), + path("favorite_topics/", ForumFavoriteTopics.as_view(), name="favorite_topics"), + path("/", ForumDetailView.as_view(), name="view_forum"), + path("/edit/", ForumEditView.as_view(), name="edit_forum"), + path("/delete/", ForumDeleteView.as_view(), name="delete_forum"), + path( + "/new_topic/", ForumTopicCreateView.as_view(), name="new_topic", ), - re_path( - r"^topic/(?P[0-9]+)$", + path( + "topic//", ForumTopicDetailView.as_view(), name="view_topic", ), - re_path( - r"^topic/(?P[0-9]+)/edit$", + path( + "topic//edit/", ForumTopicEditView.as_view(), name="edit_topic", ), - re_path( - r"^topic/(?P[0-9]+)/new_message$", + path( + "topic//new_message/", ForumMessageCreateView.as_view(), name="new_message", ), - re_path( - r"^topic/(?P[0-9]+)/toggle_subscribe$", + path( + "topic//toggle_subscribe/", ForumTopicSubscribeView.as_view(), name="toggle_subscribe_topic", ), - re_path( - r"^message/(?P[0-9]+)$", + path( + "message//", ForumMessageView.as_view(), name="view_message", ), - re_path( - r"^message/(?P[0-9]+)/edit$", + path( + "message//edit/", ForumMessageEditView.as_view(), name="edit_message", ), - re_path( - r"^message/(?P[0-9]+)/delete$", + path( + "message//delete/", ForumMessageDeleteView.as_view(), name="delete_message", ), - re_path( - r"^message/(?P[0-9]+)/undelete$", + path( + "message//undelete/", ForumMessageUndeleteView.as_view(), name="undelete_message", ), diff --git a/launderette/urls.py b/launderette/urls.py index b259c2d9..7bc214c0 100644 --- a/launderette/urls.py +++ b/launderette/urls.py @@ -22,54 +22,54 @@ # # -from django.urls import re_path +from django.urls import path from launderette.views import * urlpatterns = [ # views - re_path(r"^$", LaunderetteMainView.as_view(), name="launderette_main"), - re_path( - r"^slot/(?P[0-9]+)/delete$", + path("", LaunderetteMainView.as_view(), name="launderette_main"), + path( + "slot//delete/", SlotDeleteView.as_view(), name="delete_slot", ), - re_path(r"^book$", LaunderetteBookMainView.as_view(), name="book_main"), - re_path( - r"^book/(?P[0-9]+)$", + path("book/", LaunderetteBookMainView.as_view(), name="book_main"), + path( + "book//", LaunderetteBookView.as_view(), name="book_slot", ), - re_path( - r"^(?P[0-9]+)/click$", + path( + "/click/", LaunderetteMainClickView.as_view(), name="main_click", ), - re_path( - r"^(?P[0-9]+)/click/(?P[0-9]+)$", + path( + "/click//", LaunderetteClickView.as_view(), name="click", ), - re_path(r"^admin$", LaunderetteListView.as_view(), name="launderette_list"), - re_path( - r"^admin/(?P[0-9]+)$", + path("admin/", LaunderetteListView.as_view(), name="launderette_list"), + path( + "admin//", LaunderetteAdminView.as_view(), name="launderette_admin", ), - re_path( - r"^admin/(?P[0-9]+)/edit$", + path( + "admin//edit/", LaunderetteEditView.as_view(), name="launderette_edit", ), - re_path(r"^admin/new$", LaunderetteCreateView.as_view(), name="launderette_new"), - re_path(r"^admin/machine/new$", MachineCreateView.as_view(), name="machine_new"), - re_path( - r"^admin/machine/(?P[0-9]+)/edit$", + path("admin/new/", LaunderetteCreateView.as_view(), name="launderette_new"), + path("admin/machine/new/", MachineCreateView.as_view(), name="machine_new"), + path( + "admin/machine//edit/", MachineEditView.as_view(), name="machine_edit", ), - re_path( - r"^admin/machine/(?P[0-9]+)/delete$", + path( + "admin/machine//delete/", MachineDeleteView.as_view(), name="machine_delete", ), diff --git a/matmat/urls.py b/matmat/urls.py index 80960c59..6e657262 100644 --- a/matmat/urls.py +++ b/matmat/urls.py @@ -22,13 +22,13 @@ # # -from django.urls import re_path +from django.urls import path from matmat.views import * urlpatterns = [ - re_path(r"^$", SearchNormalFormView.as_view(), name="search"), - re_path(r"^reverse$", SearchReverseFormView.as_view(), name="search_reverse"), - re_path(r"^quick$", SearchQuickFormView.as_view(), name="search_quick"), - re_path(r"^clear$", SearchClearFormView.as_view(), name="search_clear"), + path("", SearchNormalFormView.as_view(), name="search"), + path("reverse/", SearchReverseFormView.as_view(), name="search_reverse"), + path("quick/", SearchQuickFormView.as_view(), name="search_quick"), + path("clear/", SearchClearFormView.as_view(), name="search_clear"), ] diff --git a/pedagogy/tests.py b/pedagogy/tests.py index a429bf02..d889f881 100644 --- a/pedagogy/tests.py +++ b/pedagogy/tests.py @@ -732,9 +732,9 @@ class UVSearchTest(TestCase): [ { "id": 1, - "absolute_url": "/pedagogy/uv/1", - "update_url": "/pedagogy/uv/1/edit", - "delete_url": "/pedagogy/uv/1/delete", + "absolute_url": "/pedagogy/uv/1/", + "update_url": "/pedagogy/uv/1/edit/", + "delete_url": "/pedagogy/uv/1/delete/", "code": "PA00", "author": 0, "credit_type": "OM", diff --git a/pedagogy/urls.py b/pedagogy/urls.py index 478d7ad1..8cfca8d2 100644 --- a/pedagogy/urls.py +++ b/pedagogy/urls.py @@ -22,33 +22,33 @@ # # -from django.urls import re_path +from django.urls import path from pedagogy.views import * urlpatterns = [ # Urls displaying the actual application for visitors - re_path(r"^$", UVListView.as_view(), name="guide"), - re_path(r"^uv/(?P[0-9]+)$", UVDetailFormView.as_view(), name="uv_detail"), - re_path( - r"^comment/(?P[0-9]+)/edit$", + path("", UVListView.as_view(), name="guide"), + path("uv//", UVDetailFormView.as_view(), name="uv_detail"), + path( + "comment//edit/", UVCommentUpdateView.as_view(), name="comment_update", ), - re_path( - r"^comment/(?P[0-9]+)/delete$", + path( + "comment//delete/", UVCommentDeleteView.as_view(), name="comment_delete", ), - re_path( - r"^comment/(?P[0-9]+)/report$", + path( + "comment//report/", UVCommentReportCreateView.as_view(), name="comment_report", ), # Moderation - re_path(r"^moderation$", UVModerationFormView.as_view(), name="moderation"), + path("moderation/", UVModerationFormView.as_view(), name="moderation"), # Administration : Create Update Delete Edit - re_path(r"^uv/create$", UVCreateView.as_view(), name="uv_create"), - re_path(r"^uv/(?P[0-9]+)/delete$", UVDeleteView.as_view(), name="uv_delete"), - re_path(r"^uv/(?P[0-9]+)/edit$", UVUpdateView.as_view(), name="uv_update"), + path("uv/create/", UVCreateView.as_view(), name="uv_create"), + path("uv//delete/", UVDeleteView.as_view(), name="uv_delete"), + path("uv//edit/", UVUpdateView.as_view(), name="uv_update"), ] diff --git a/rootplace/urls.py b/rootplace/urls.py index 33b3bd6d..696fb81e 100644 --- a/rootplace/urls.py +++ b/rootplace/urls.py @@ -23,16 +23,16 @@ # # -from django.urls import re_path +from django.urls import path from rootplace.views import * urlpatterns = [ - re_path(r"^merge$", MergeUsersView.as_view(), name="merge"), - re_path( - r"^forum/messages/delete$", + path("merge/", MergeUsersView.as_view(), name="merge"), + path( + "forum/messages/delete/", DeleteAllForumUserMessagesView.as_view(), name="delete_forum_messages", ), - re_path(r"^logs$", OperationLogListView.as_view(), name="operation_logs"), + path("logs/", OperationLogListView.as_view(), name="operation_logs"), ] diff --git a/sas/urls.py b/sas/urls.py index fada615f..28a2a152 100644 --- a/sas/urls.py +++ b/sas/urls.py @@ -22,40 +22,36 @@ # # -from django.urls import re_path +from django.urls import path from sas.views import * urlpatterns = [ - re_path(r"^$", SASMainView.as_view(), name="main"), - re_path(r"^moderation$", ModerationView.as_view(), name="moderation"), - re_path(r"^album/(?P[0-9]+)$", AlbumView.as_view(), name="album"), - re_path( - r"^album/(?P[0-9]+)/upload$", + path("", SASMainView.as_view(), name="main"), + path("moderation/", ModerationView.as_view(), name="moderation"), + path("album//", AlbumView.as_view(), name="album"), + path( + "album//upload/", AlbumUploadView.as_view(), name="album_upload", ), - re_path( - r"^album/(?P[0-9]+)/edit$", AlbumEditView.as_view(), name="album_edit" - ), - re_path(r"^album/(?P[0-9]+)/preview$", send_album, name="album_preview"), - re_path(r"^picture/(?P[0-9]+)$", PictureView.as_view(), name="picture"), - re_path( - r"^picture/(?P[0-9]+)/edit$", + path("album//edit/", AlbumEditView.as_view(), name="album_edit"), + path("album//preview/", send_album, name="album_preview"), + path("picture//", PictureView.as_view(), name="picture"), + path( + "picture//edit/", PictureEditView.as_view(), name="picture_edit", ), - re_path(r"^picture/(?P[0-9]+)/download$", send_pict, name="download"), - re_path( - r"^picture/(?P[0-9]+)/download/compressed$", + path("picture//download/", send_pict, name="download"), + path( + "picture//download/compressed/", send_compressed, name="download_compressed", ), - re_path( - r"^picture/(?P[0-9]+)/download/thumb$", + path( + "picture//download/thumb/", send_thumb, name="download_thumb", ), - # re_path(r'^album/new$', AlbumCreateView.as_view(), name='album_new'), - # re_path(r'^(?P[0-9]+)/$', ClubView.as_view(), name='club_view'), ] diff --git a/stock/urls.py b/stock/urls.py index 59bc466b..cf7ff13f 100644 --- a/stock/urls.py +++ b/stock/urls.py @@ -23,67 +23,65 @@ # # -from django.urls import include, re_path +from django.urls import path from stock.views import * urlpatterns = [ # Stock re_paths - re_path( - r"^new/counter/(?P[0-9]+)$", StockCreateView.as_view(), name="new" - ), - re_path(r"^edit/(?P[0-9]+)$", StockEditView.as_view(), name="edit"), - re_path(r"^list$", StockListView.as_view(), name="list"), + path("new/counter//", StockCreateView.as_view(), name="new"), + path("edit//", StockEditView.as_view(), name="edit"), + path("list/", StockListView.as_view(), name="list"), # StockItem re_paths - re_path(r"^(?P[0-9]+)$", StockItemList.as_view(), name="items_list"), - re_path( - r"^(?P[0-9]+)/stock_item/new_item$", + path("/", StockItemList.as_view(), name="items_list"), + path( + "/stock_item/new_item/", StockItemCreateView.as_view(), name="new_item", ), - re_path( - r"^stock_item/(?P[0-9]+)/edit$", + path( + "stock_item//edit/", StockItemEditView.as_view(), name="edit_item", ), - re_path( - r"^(?P[0-9]+)/stock_item/take_items$", + path( + "/stock_item/take_items/", StockTakeItemsBaseFormView.as_view(), name="take_items", ), # ShoppingList re_paths - re_path( - r"^(?P[0-9]+)/shopping_list/list$", + path( + "/shopping_list/list/", StockShoppingListView.as_view(), name="shoppinglist_list", ), - re_path( - r"^(?P[0-9]+)/shopping_list/create$", + path( + "/shopping_list/create/", StockItemQuantityBaseFormView.as_view(), name="shoppinglist_create", ), - re_path( - r"^(?P[0-9]+)/shopping_list/(?P[0-9]+)/items$", + path( + "/shopping_list//items/", StockShoppingListItemListView.as_view(), name="shoppinglist_items", ), - re_path( - r"^(?P[0-9]+)/shopping_list/(?P[0-9]+)/delete$", + path( + "/shopping_list//delete/", StockShoppingListDeleteView.as_view(), name="shoppinglist_delete", ), - re_path( - r"^(?P[0-9]+)/shopping_list/(?P[0-9]+)/set_done$", + path( + "/shopping_list//set_done/", StockShopppingListSetDone.as_view(), name="shoppinglist_set_done", ), - re_path( - r"^(?P[0-9]+)/shopping_list/(?P[0-9]+)/set_todo$", + path( + "/shopping_list//set_todo/", StockShopppingListSetTodo.as_view(), name="shoppinglist_set_todo", ), - re_path( - r"^(?P[0-9]+)/shopping_list/(?P[0-9]+)/update_stock$", + path( + "/shopping_list//update_stock/", StockUpdateAfterShopppingBaseFormView.as_view(), name="update_after_shopping", ), diff --git a/subscription/urls.py b/subscription/urls.py index d398197a..daf1c7d1 100644 --- a/subscription/urls.py +++ b/subscription/urls.py @@ -22,12 +22,12 @@ # # -from django.urls import re_path +from django.urls import path from subscription.views import * urlpatterns = [ # Subscription views - re_path(r"^$", NewSubscription.as_view(), name="subscription"), - re_path(r"stats", SubscriptionsStatsView.as_view(), name="stats"), + path("", NewSubscription.as_view(), name="subscription"), + path("stats/", SubscriptionsStatsView.as_view(), name="stats"), ] diff --git a/trombi/urls.py b/trombi/urls.py index 9858ea65..49ac42db 100644 --- a/trombi/urls.py +++ b/trombi/urls.py @@ -23,67 +23,65 @@ # # -from django.urls import re_path +from django.urls import path from trombi.views import * urlpatterns = [ - re_path(r"^(?P[0-9]+)/new$", TrombiCreateView.as_view(), name="create"), - re_path( - r"^(?P[0-9]+)/export$", TrombiExportView.as_view(), name="export" - ), - re_path(r"^(?P[0-9]+)/edit$", TrombiEditView.as_view(), name="edit"), - re_path( - r"^(?P[0-9]+)/moderate_comments$", + path("/new/", TrombiCreateView.as_view(), name="create"), + path("/export/", TrombiExportView.as_view(), name="export"), + path("/edit/", TrombiEditView.as_view(), name="edit"), + path( + "/moderate_comments/", TrombiModerateCommentsView.as_view(), name="moderate_comments", ), - re_path( - r"^(?P[0-9]+)/moderate$", + path( + "/moderate/", TrombiModerateCommentView.as_view(), name="moderate_comment", ), - re_path( - r"^user/(?P[0-9]+)/delete$", + path( + "user//delete/", TrombiDeleteUserView.as_view(), name="delete_user", ), - re_path(r"^(?P[0-9]+)$", TrombiDetailView.as_view(), name="detail"), - re_path( - r"^(?P[0-9]+)/new_comment$", + path("/", TrombiDetailView.as_view(), name="detail"), + path( + "/new_comment/", TrombiCommentCreateView.as_view(), name="new_comment", ), - re_path( - r"^(?P[0-9]+)/profile$", + path( + "/profile/", UserTrombiProfileView.as_view(), name="user_profile", ), - re_path( - r"^comment/(?P[0-9]+)/edit$", + path( + "comment//edit/", TrombiCommentEditView.as_view(), name="edit_comment", ), - re_path(r"^tools$", UserTrombiToolsView.as_view(), name="user_tools"), - re_path(r"^profile$", UserTrombiEditProfileView.as_view(), name="profile"), - re_path(r"^pictures$", UserTrombiEditPicturesView.as_view(), name="pictures"), - re_path( - r"^reset_memberships$", + path("tools/", UserTrombiToolsView.as_view(), name="user_tools"), + path("profile/", UserTrombiEditProfileView.as_view(), name="profile"), + path("pictures/", UserTrombiEditPicturesView.as_view(), name="pictures"), + path( + "reset_memberships/", UserTrombiResetClubMembershipsView.as_view(), name="reset_memberships", ), - re_path( - r"^membership/(?P[0-9]+)/edit$", + path( + "membership//edit/", UserTrombiEditMembershipView.as_view(), name="edit_membership", ), - re_path( - r"^membership/(?P[0-9]+)/delete$", + path( + "membership//delete/", UserTrombiDeleteMembershipView.as_view(), name="delete_membership", ), - re_path( - r"^membership/(?P[0-9]+)/create$", + path( + "membership//create/", UserTrombiAddMembershipView.as_view(), name="create_membership", ),