From 858a0c61e266f9d8409edcda2d6b330e57e39953 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 11 Aug 2020 17:19:32 +0200 Subject: [PATCH 1/7] =?UTF-8?q?Rend=20=C3=A0=20gestiocof=20ce=20qui=20est?= =?UTF-8?q?=20=C3=A0=20gestiocof?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cof/urls.py | 96 +--------------------------------------- gestioncof/urls.py | 108 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 107 insertions(+), 97 deletions(-) diff --git a/cof/urls.py b/cof/urls.py index af7501d1..3375a0d6 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -5,14 +5,10 @@ from django.conf import settings from django.conf.urls.i18n import i18n_patterns 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.generic.base import TemplateView -from django_cas_ng import views as django_cas_views +# Website administration (independent from installed apps) admin.autodiscover() - - urlpatterns = [ path("admin/doc/", include("django.contrib.admindocs.urls")), path("admin/", admin.site.urls), @@ -23,14 +19,6 @@ if "gestioncof" in settings.INSTALLED_APPS: from wagtail.admin import urls as wagtailadmin_urls from wagtail.documents import urls as wagtaildocs_urls - from gestioncof import csv_views, views as gestioncof_views - from gestioncof.urls import ( - calendar_patterns, - clubs_patterns, - events_patterns, - export_patterns, - surveys_patterns, - ) # Also includes BdA, K-Fêt, etc. urlpatterns += [ @@ -44,93 +32,11 @@ if "gestioncof" in settings.INSTALLED_APPS: 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", - gestioncof_views.RegistrationAutocompleteView.as_view(), - name="cof.registration.autocomplete", - ), - path( - "user/autocomplete", - gestioncof_views.UserAutocompleteView.as_view(), - 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"), ] diff --git a/gestioncof/urls.py b/gestioncof/urls.py index 6a07eac9..2e896eed 100644 --- a/gestioncof/urls.py +++ b/gestioncof/urls.py @@ -1,6 +1,9 @@ -from django.urls import path +from django.contrib.auth import views as django_auth_views +from django.urls import include, path +from django.views.generic.base import TemplateView +from django_cas_ng import views as django_cas_views -from gestioncof import views +from gestioncof import csv_views, views export_patterns = [ path("members", views.export_members, name="cof.membres_export"), @@ -42,3 +45,104 @@ clubs_patterns = [ name="change-respo", ), ] + +registration_patterns = [ + # Inscription d'un nouveau membre + path("", views.registration, name="registration"), + path( + "clipper//", + views.registration_form2, + name="clipper-registration", + ), + path("user/", views.registration_form2, name="user-registration",), + path("empty", views.registration_form2, name="empty-registration",), + # Autocompletion + path( + "autocomplete", + views.RegistrationAutocompleteView.as_view(), + name="cof.registration.autocomplete", + ), +] + +urlpatterns = [ + path( + "admin///csv/", + csv_views.admin_list_export, + {"fields": ["username"]}, + ), + # ----- + # Misc + # ----- + path("", views.HomeView.as_view(), name="home"), + path( + "user/autocomplete", + views.UserAutocompleteView.as_view(), + name="cof-user-autocomplete", + ), + path("config", views.ConfigUpdate.as_view(), name="config.edit"), + # ----- + # 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", views.LoginExtView.as_view(), name="ext_login_view",), + path( + "outsider/logout", + django_auth_views.LogoutView.as_view(), + {"next_page": "home"}, + ), + path("login", views.login, name="cof-login"), + path("logout", views.logout, name="cof-logout"), + path("admin/logout/", views.logout), + # ----- + # Infos persos + # ----- + path("profile", 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", + ), + # ----- + # Liens utiles du COF et du BdA + # ----- + path("utile_cof", views.utile_cof, name="utile_cof"), + path("utile_bda", views.utile_bda, name="utile_bda"), + path("utile_bda/bda_diff", views.liste_bdadiff, name="ml_diffbda"), + path("utile_cof/diff_cof", views.liste_diffcof, name="ml_diffcof"), + path("utile_bda/bda_revente", views.liste_bdarevente, name="ml_bda_revente",), + # ----- + # Inscription d'un nouveau membre + # ----- + path("registration/", include(registration_patterns)), + # ----- + # Les exports + # ----- + path("export/", include(export_patterns)), + # ----- + # 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)), +] From 5f8b8661bfbec8867aa410132676afcbf89ed5cf Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 11 Aug 2020 17:20:52 +0200 Subject: [PATCH 2/7] Better URL management --- cof/urls.py | 59 +++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/cof/urls.py b/cof/urls.py index 3375a0d6..774169c5 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -14,45 +14,30 @@ urlpatterns = [ path("admin/", admin.site.urls), ] -if "gestioncof" in settings.INSTALLED_APPS: +# App-specific urls +# TODO : mettre le préfixe de bds à "" sur gestioBDS ? +app_dict = { + "bds": "bds/", + "gestioncof": "", + "bda": "bda/", + "petitscours": "petitcours/", + "kfet": "k-fet", + # events module is still experimental ! + "events": "event_v2/", + "authens": "authens/", +} +for (app_name, url_prefix) in app_dict.items(): + if app_name in settings.INSTALLED_APPS: + urlpatterns += [path(url_prefix, include("{}.urls".format(app_name)))] + + +if "django_js_reverse" in settings.INSTALLED_APPS: 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 petits cours - path("petitcours/", include("petitscours.urls")), - path("k-fet/", include("kfet.urls")), - path("cms/", include(wagtailadmin_urls)), - path("documents/", include(wagtaildocs_urls)), - # 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 - # → rename this when the old events system is out - urlpatterns += [path("event_v2/", include("events.urls"))] - -if "authens" in settings.INSTALLED_APPS: - urlpatterns.append(path("authens/", include("authens.urls"))) - if "debug_toolbar" in settings.INSTALLED_APPS: import debug_toolbar @@ -63,10 +48,16 @@ if settings.DEBUG: # Il faut dire à Django de servir MEDIA_ROOT lui-même en développement. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -# Wagtail for uncatched +# Wagtail URLs (wagtail.core urls must be last, as catch-all) if "wagtail.core" in settings.INSTALLED_APPS: from wagtail.core import urls as wagtail_urls + from wagtail.admin import urls as wagtailadmin_urls + from wagtail.documents import urls as wagtaildocs_urls + urlpatterns += [ + path("cms/", include(wagtailadmin_urls)), + path("documents/", include(wagtaildocs_urls)), + ] urlpatterns += i18n_patterns( path("", include(wagtail_urls)), prefix_default_language=False ) From ab9b4d14efb0ead6658b9265b5947c383d2b17ef Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 11 Aug 2020 17:20:59 +0200 Subject: [PATCH 3/7] Some changes to mega urls --- .../templates/gestioncof/utile_cof.html | 30 +++++++++---------- gestioncof/urls.py | 12 ++++---- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/gestioncof/templates/gestioncof/utile_cof.html b/gestioncof/templates/gestioncof/utile_cof.html index 637055c5..89b8ec23 100644 --- a/gestioncof/templates/gestioncof/utile_cof.html +++ b/gestioncof/templates/gestioncof/utile_cof.html @@ -4,21 +4,21 @@ {% endblock %} {% block realcontent %} -

Liens utiles du COF

-

COF

- +

Liens utiles du COF

+

COF

+ -

Mega

- +

Mega

+ -

Note : pour ouvrir les fichiers .csv avec Excel, il faut - passer par Fichier > Importer et sélectionner la - virgule comme séparateur.

+

Note : pour ouvrir les fichiers .csv avec Excel, il faut + passer par Fichier > Importer et sélectionner la + virgule comme séparateur.

{% endblock %} diff --git a/gestioncof/urls.py b/gestioncof/urls.py index 2e896eed..dd055938 100644 --- a/gestioncof/urls.py +++ b/gestioncof/urls.py @@ -6,19 +6,17 @@ from django_cas_ng import views as django_cas_views from gestioncof import csv_views, views export_patterns = [ - path("members", views.export_members, name="cof.membres_export"), + path("members", views.export_members, name="export.membres"), path( - "mega/avecremarques", - views.export_mega_remarksonly, - name="cof.mega_export_remarks", + "mega/avecremarques", views.export_mega_remarksonly, name="export.mega.remarks", ), path( "mega/participants", views.export_mega_participants, - name="cof.mega_export_participants", + name="export.mega.participants", ), - path("mega/orgas", views.export_mega_orgas, name="cof.mega_export_orgas"), - path("mega", views.export_mega, name="cof.mega_export"), + path("mega/orgas", views.export_mega_orgas, name="export.mega.orgas"), + path("mega/all", views.export_mega, name="export.mega.all"), ] surveys_patterns = [ From 205b5c206bfdb2f51af4f5d6d1d78c18243133e7 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 11 Aug 2020 17:38:57 +0200 Subject: [PATCH 4/7] Fix tests --- cof/urls.py | 2 +- gestioncof/templates/gestioncof/utile_cof.html | 2 +- gestioncof/tests/test_views.py | 16 ++++++++-------- gestioncof/urls.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cof/urls.py b/cof/urls.py index 774169c5..6a1ed9e2 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -21,7 +21,7 @@ app_dict = { "gestioncof": "", "bda": "bda/", "petitscours": "petitcours/", - "kfet": "k-fet", + "kfet": "k-fet/", # events module is still experimental ! "events": "event_v2/", "authens": "authens/", diff --git a/gestioncof/templates/gestioncof/utile_cof.html b/gestioncof/templates/gestioncof/utile_cof.html index 89b8ec23..71a3b865 100644 --- a/gestioncof/templates/gestioncof/utile_cof.html +++ b/gestioncof/templates/gestioncof/utile_cof.html @@ -7,7 +7,7 @@

Liens utiles du COF

COF

diff --git a/gestioncof/tests/test_views.py b/gestioncof/tests/test_views.py index ac18573e..682d85f2 100644 --- a/gestioncof/tests/test_views.py +++ b/gestioncof/tests/test_views.py @@ -26,7 +26,7 @@ User = get_user_model() class RegistrationViewTests(ViewTestCaseMixin, TestCase): url_name = "registration" - url_expected = "/registration" + url_expected = "/registration/" http_methods = ["GET", "POST"] @@ -269,7 +269,7 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase): @override_settings(LDAP_SERVER_URL="ldap_url") class RegistrationAutocompleteViewTests(MockLDAPMixin, ViewTestCaseMixin, TestCase): url_name = "cof.registration.autocomplete" - url_expected = "/autocomplete/registration" + url_expected = "/registration/autocomplete" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -480,7 +480,7 @@ class UserAutocompleteViewTests(ViewTestCaseMixin, TestCase): class ExportMembersViewTests(CSVResponseMixin, ViewTestCaseMixin, TestCase): - url_name = "cof.membres_export" + url_name = "export.members" url_expected = "/export/members" auth_user = "staff" @@ -520,8 +520,8 @@ class ExportMembersViewTests(CSVResponseMixin, ViewTestCaseMixin, TestCase): class ExportMegaViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): - url_name = "cof.mega_export" - url_expected = "/export/mega" + url_name = "export.mega.all" + url_expected = "/export/mega/all" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -549,7 +549,7 @@ class ExportMegaViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): class ExportMegaOrgasViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): - url_name = "cof.mega_export_orgas" + url_name = "export.mega.orgas" url_expected = "/export/mega/orgas" auth_user = "staff" @@ -578,7 +578,7 @@ class ExportMegaOrgasViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): class ExportMegaParticipantsViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): - url_name = "cof.mega_export_participants" + url_name = "export.mega.participants" url_expected = "/export/mega/participants" auth_user = "staff" @@ -595,7 +595,7 @@ class ExportMegaParticipantsViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCa class ExportMegaRemarksViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): - url_name = "cof.mega_export_remarks" + url_name = "export.mega.remarks" url_expected = "/export/mega/avecremarques" auth_user = "staff" diff --git a/gestioncof/urls.py b/gestioncof/urls.py index dd055938..677a3efe 100644 --- a/gestioncof/urls.py +++ b/gestioncof/urls.py @@ -6,7 +6,7 @@ from django_cas_ng import views as django_cas_views from gestioncof import csv_views, views export_patterns = [ - path("members", views.export_members, name="export.membres"), + path("members", views.export_members, name="export.members"), path( "mega/avecremarques", views.export_mega_remarksonly, name="export.mega.remarks", ), From fc988e3fad1a6a83265938820ab4bb706c0fbb42 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 11 Aug 2020 17:42:56 +0200 Subject: [PATCH 5/7] Fix isort --- cof/urls.py | 2 +- setup.cfg | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cof/urls.py b/cof/urls.py index 6a1ed9e2..d96b14c4 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -50,8 +50,8 @@ if settings.DEBUG: # Wagtail URLs (wagtail.core urls must be last, as catch-all) if "wagtail.core" in settings.INSTALLED_APPS: - from wagtail.core import urls as wagtail_urls from wagtail.admin import urls as wagtailadmin_urls + from wagtail.core import urls as wagtail_urls from wagtail.documents import urls as wagtaildocs_urls urlpatterns += [ diff --git a/setup.cfg b/setup.cfg index 995af0a4..8aa73856 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,6 @@ combine_as_imports = true default_section = THIRDPARTY force_grid_wrap = 0 include_trailing_comma = true -known_django = django known_first_party = bda,bds,clubs,cof,events,gestioncof,kfet,petitscours,shared line_length = 88 multi_line_output = 3 From e868e6eb182add3a8f32a9be4cb0693b69605a13 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 1 Sep 2020 15:17:10 +0200 Subject: [PATCH 6/7] No bds prefix for prod --- cof/urls.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cof/urls.py b/cof/urls.py index d96b14c4..5e49ba0a 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -15,9 +15,13 @@ urlpatterns = [ ] # App-specific urls -# TODO : mettre le préfixe de bds à "" sur gestioBDS ? + +bds_is_alone = ( + "bds" in settings.INSTALLED_APPS and "gestioncof" not in settings.INSTALLED_APPS +) + app_dict = { - "bds": "bds/", + "bds": "" if bds_is_alone else "bds/", "gestioncof": "", "bda": "bda/", "petitscours": "petitcours/", From 1387da3b54597b155736bf8f49b3e1c53ff8a9f0 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 1 Sep 2020 15:35:18 +0200 Subject: [PATCH 7/7] black 20 --- gestioncof/urls.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/gestioncof/urls.py b/gestioncof/urls.py index 677a3efe..14fb101f 100644 --- a/gestioncof/urls.py +++ b/gestioncof/urls.py @@ -8,7 +8,9 @@ from gestioncof import csv_views, views export_patterns = [ path("members", views.export_members, name="export.members"), path( - "mega/avecremarques", views.export_mega_remarksonly, name="export.mega.remarks", + "mega/avecremarques", + views.export_mega_remarksonly, + name="export.mega.remarks", ), path( "mega/participants", @@ -52,8 +54,16 @@ registration_patterns = [ views.registration_form2, name="clipper-registration", ), - path("user/", views.registration_form2, name="user-registration",), - path("empty", views.registration_form2, name="empty-registration",), + path( + "user/", + views.registration_form2, + name="user-registration", + ), + path( + "empty", + views.registration_form2, + name="empty-registration", + ), # Autocompletion path( "autocomplete", @@ -88,7 +98,11 @@ urlpatterns = [ ), 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", views.LoginExtView.as_view(), name="ext_login_view",), + path( + "outsider/login", + views.LoginExtView.as_view(), + name="ext_login_view", + ), path( "outsider/logout", django_auth_views.LogoutView.as_view(), @@ -118,7 +132,11 @@ urlpatterns = [ path("utile_bda", views.utile_bda, name="utile_bda"), path("utile_bda/bda_diff", views.liste_bdadiff, name="ml_diffbda"), path("utile_cof/diff_cof", views.liste_diffcof, name="ml_diffcof"), - path("utile_bda/bda_revente", views.liste_bdarevente, name="ml_bda_revente",), + path( + "utile_bda/bda_revente", + views.liste_bdarevente, + name="ml_bda_revente", + ), # ----- # Inscription d'un nouveau membre # -----