From 0d8c97dbf7a8681c986baef0e0408329f8a40c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 9 May 2020 16:21:40 +0200 Subject: [PATCH] One url file to rule them all, one url file to find them One url file to bring them all, and in the darkness bind them. --- bds/urls.py | 2 + cof/urls.py | 241 ++++++++++++++++++++++++++++------------------------ 2 files changed, 130 insertions(+), 113 deletions(-) create mode 100644 bds/urls.py diff --git a/bds/urls.py b/bds/urls.py new file mode 100644 index 00000000..e4487422 --- /dev/null +++ b/bds/urls.py @@ -0,0 +1,2 @@ +app_label = "bds" +urlpatterns = [] diff --git a/cof/urls.py b/cof/urls.py index 374c0f1a..12cf4f5a 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -8,129 +8,141 @@ from django.conf.urls.static import static from django.contrib import admin from django.contrib.auth import views as django_auth_views from django.urls import include, path -from django.views.decorators.cache import cache_page from django.views.generic.base import TemplateView from django_cas_ng import views as django_cas_views -from django_js_reverse.views import urls_js -from wagtail.admin import urls as wagtailadmin_urls -from wagtail.core import urls as wagtail_urls -from wagtail.documents import urls as wagtaildocs_urls - -from gestioncof import csv_views, views as gestioncof_views -from gestioncof.autocomplete import autocomplete -from gestioncof.urls import ( - calendar_patterns, - clubs_patterns, - events_patterns, - export_patterns, - surveys_patterns, -) admin.autodiscover() + urlpatterns = [ - # Page d'accueil - path("", gestioncof_views.HomeView.as_view(), name="home"), - # Le BdA - path("bda/", include("bda.urls")), - # Les exports - path("export/", include(export_patterns)), - # Les petits cours - path("petitcours/", include("petitscours.urls")), - # Les sondages - path("survey/", include(surveys_patterns)), - # Evenements - path("event/", include(events_patterns)), - # Calendrier - path("calendar/", include(calendar_patterns)), - # Clubs - path("clubs/", include(clubs_patterns)), - # Authentification - path( - "cof/denied", - TemplateView.as_view(template_name="cof-denied.html"), - name="cof-denied", - ), - path("cas/login", django_cas_views.LoginView.as_view(), name="cas_login_view"), - path("cas/logout", django_cas_views.LogoutView.as_view()), - path( - "outsider/login", gestioncof_views.LoginExtView.as_view(), name="ext_login_view" - ), - path( - "outsider/logout", django_auth_views.LogoutView.as_view(), {"next_page": "home"} - ), - path("login", gestioncof_views.login, name="cof-login"), - path("logout", gestioncof_views.logout, name="cof-logout"), - # Infos persos - path("profile", gestioncof_views.profile, name="profile"), - path( - "outsider/password-change", - django_auth_views.PasswordChangeView.as_view(), - name="password_change", - ), - path( - "outsider/password-change-done", - django_auth_views.PasswordChangeDoneView.as_view(), - name="password_change_done", - ), - # Inscription d'un nouveau membre - path("registration", gestioncof_views.registration, name="registration"), - path( - "registration/clipper//", - gestioncof_views.registration_form2, - name="clipper-registration", - ), - path( - "registration/user/", - gestioncof_views.registration_form2, - name="user-registration", - ), - path( - "registration/empty", - gestioncof_views.registration_form2, - name="empty-registration", - ), - # Autocompletion - path( - "autocomplete/registration", autocomplete, name="cof.registration.autocomplete" - ), - path( - "user/autocomplete", - gestioncof_views.user_autocomplete, - name="cof-user-autocomplete", - ), - # Interface admin - path("admin/logout/", gestioncof_views.logout), path("admin/doc/", include("django.contrib.admindocs.urls")), - path( - "admin///csv/", - csv_views.admin_list_export, - {"fields": ["username"]}, - ), path("admin/", admin.site.urls), - # Liens utiles du COF et du BdA - path("utile_cof", gestioncof_views.utile_cof, name="utile_cof"), - path("utile_bda", gestioncof_views.utile_bda, name="utile_bda"), - path("utile_bda/bda_diff", gestioncof_views.liste_bdadiff, name="ml_diffbda"), - path("utile_cof/diff_cof", gestioncof_views.liste_diffcof, name="ml_diffcof"), - path( - "utile_bda/bda_revente", - gestioncof_views.liste_bdarevente, - name="ml_bda_revente", - ), - path("k-fet/", include("kfet.urls")), - path("cms/", include(wagtailadmin_urls)), - path("documents/", include(wagtaildocs_urls)), - # djconfig - path("config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"), - # js-reverse - path("jsreverse/", urls_js, name="js_reverse"), ] +if "gestioncof" in settings.INSTALLED_APPS: + from gestioncof import csv_views, views as gestioncof_views + from gestioncof.autocomplete import autocomplete + from gestioncof.urls import ( + calendar_patterns, + clubs_patterns, + events_patterns, + export_patterns, + surveys_patterns, + ) + from django_js_reverse.views import urls_js + from wagtail.admin import urls as wagtailadmin_urls + from wagtail.documents import urls as wagtaildocs_urls + + # Also includes BdA, K-Fêt, etc. + urlpatterns += [ + path("admin/logout/", gestioncof_views.logout), + path( + "admin///csv/", + csv_views.admin_list_export, + {"fields": ["username"]}, + ), + # Page d'accueil + path("", gestioncof_views.HomeView.as_view(), name="home"), + # Le BdA + path("bda/", include("bda.urls")), + # Les exports + path("export/", include(export_patterns)), + # Les petits cours + path("petitcours/", include("petitscours.urls")), + # Les sondages + path("survey/", include(surveys_patterns)), + # Evenements + path("event/", include(events_patterns)), + # Calendrier + path("calendar/", include(calendar_patterns)), + # Clubs + path("clubs/", include(clubs_patterns)), + # Authentification + path( + "cof/denied", + TemplateView.as_view(template_name="cof-denied.html"), + name="cof-denied", + ), + path("cas/login", django_cas_views.LoginView.as_view(), name="cas_login_view"), + path("cas/logout", django_cas_views.LogoutView.as_view()), + path( + "outsider/login", + gestioncof_views.LoginExtView.as_view(), + name="ext_login_view", + ), + path( + "outsider/logout", + django_auth_views.LogoutView.as_view(), + {"next_page": "home"}, + ), + path("login", gestioncof_views.login, name="cof-login"), + path("logout", gestioncof_views.logout, name="cof-logout"), + # Infos persos + path("profile", gestioncof_views.profile, name="profile"), + path( + "outsider/password-change", + django_auth_views.PasswordChangeView.as_view(), + name="password_change", + ), + path( + "outsider/password-change-done", + django_auth_views.PasswordChangeDoneView.as_view(), + name="password_change_done", + ), + # Inscription d'un nouveau membre + path("registration", gestioncof_views.registration, name="registration"), + path( + "registration/clipper//", + gestioncof_views.registration_form2, + name="clipper-registration", + ), + path( + "registration/user/", + gestioncof_views.registration_form2, + name="user-registration", + ), + path( + "registration/empty", + gestioncof_views.registration_form2, + name="empty-registration", + ), + # Autocompletion + path( + "autocomplete/registration", + autocomplete, + name="cof.registration.autocomplete", + ), + path( + "user/autocomplete", + gestioncof_views.user_autocomplete, + name="cof-user-autocomplete", + ), + # Liens utiles du COF et du BdA + path("utile_cof", gestioncof_views.utile_cof, name="utile_cof"), + path("utile_bda", gestioncof_views.utile_bda, name="utile_bda"), + path("utile_bda/bda_diff", gestioncof_views.liste_bdadiff, name="ml_diffbda"), + path("utile_cof/diff_cof", gestioncof_views.liste_diffcof, name="ml_diffcof"), + path( + "utile_bda/bda_revente", + gestioncof_views.liste_bdarevente, + name="ml_bda_revente", + ), + path("k-fet/", include("kfet.urls")), + path("cms/", include(wagtailadmin_urls)), + path("documents/", include(wagtaildocs_urls)), + # djconfig + path("config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"), + # js-reverse + path("jsreverse/", urls_js, name="js_reverse"), + ] + +if "bds" in settings.INSTALLED_APPS: + urlpatterns.append(path("bds/", include("bds.urls"))) + if "events" in settings.INSTALLED_APPS: # The new event application is still in development # → for now it is namespaced below events_v2 - # → when the old events system is out, move this above in the others apps + # → rename this when the old events system is out urlpatterns += [path("event_v2/", include("events.urls"))] if "debug_toolbar" in settings.INSTALLED_APPS: @@ -144,6 +156,9 @@ if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # Wagtail for uncatched -urlpatterns += i18n_patterns( - path("", include(wagtail_urls)), prefix_default_language=False -) +if "wagtail.core" in settings.INSTALLED_APPS: + from wagtail.core import urls as wagtail_urls + + urlpatterns += i18n_patterns( + path("", include(wagtail_urls)), prefix_default_language=False + )