kpsul/cof/urls.py

142 lines
4.7 KiB
Python
Raw Normal View History

2016-11-06 15:39:14 +01:00
"""
Fichier principal de configuration des urls du projet GestioCOF
"""
2016-07-09 19:49:38 +02:00
from django.conf import settings
from django.conf.urls import include, url
2018-02-03 22:34:37 +01:00
from django.conf.urls.i18n import i18n_patterns
2016-07-09 19:49:38 +02:00
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth import views as django_views
from django.views.generic.base import TemplateView
from django_cas_ng import views as django_cas_views
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
url(r"^$", gestioncof_views.home, name="home"),
# Le BdA
url(r"^bda/", include("bda.urls")),
# Les exports
url(r"^export/", include(export_patterns)),
# Les petits cours
Extrait les petits cours dans une application séparée L'application `petitscours` reste assez fortement couplée à `gestioncof`, et n'est pas (encore ?) faite pour être utilisée séparément. De façon similaire, et afin de minimiser de potentiels problèmes dûs à des migrations, les modèles de l'application `petitscours` utilisent `app_label = "gestioncof"` pour que Django les considère comme faisant partie de l'application `"gestioncof"`. Ils pourront être migrés dans un second temps si cela s'avère nécessaire. Les changements sont nombreux, mais assez simples: il s'agit principalement de déplacer des fichiers et changer des imports. J'ai également profité de l'occasion pour réorganiser les templates afin de les placer dans l'espace de nom "petitscours/". cof/ * settings/common.py: Add `petitscours` app * urls.py: Use `petitscours.urls` petitscours/ * __init__.py: Added. * tests/__init__.py: Added. * tests/utils.py: Added. * urls.py: Added. gestioncof/ * admin.py: * management/commands/loaddevdata.py: * models.py: * signals.py: Typo. * urls.py: Moved petitscours_patterns to petitscours.urls * petits_cours_forms.py: Moved to petitscours/forms.py * petits_cours_models.py: Moved to petitscours/models.py * petits_cours_views.py: Moved to petitscours/views.py * tests/utils.py: * tests/test_petitscours_views.py: Moved to petitscours/tests/test_petitscours_views.py * templates/base_title_petitscours.html: Moved to petitscours/templates/petitscours/base_title.html * templates/demande-petit-cours.html: Moved topetitscours/templates/petitscours/demande.html * templates/gestioncof/details_demande_petit_cours.html: Moved to petitscours/templates/petitscours/demande_detail.html * templates/petits_cours_demandes_list.html: Moved to petitscours/templates/petitscours/demande_list.html * templates/demande-petit-cours-raw.html: Moved to petitscours/templates/petitscours/demande_raw.html * templates/details_demande_petit_cours_infos.html: Moved to petitscours/templates/petitscours/details_demande_infos.html * templates/inscription-petit-cours.html: Moved to petitscours/templates/petitscours/inscription.html * templates/inscription-petit-cours-formset.html: Moved to petitscours/templates/petitscours/inscription_formset.html * templates/gestioncof/traitement_demande_petit_cours.html: Moved to petitscours/templates/petitscours/traitement_demande.html * templates/gestioncof/traitement_demande_petit_cours_autre_niveau.html: Moved to petitscours/templates/petitscours/traitement_demande_autre_niveau.html * templates/gestioncof/traitement_demande_petit_cours_success.html: Moved to petitscours/templates/petitscours/traitement_demande_success.html
2018-11-25 00:37:22 +01:00
url(r"^petitcours/", include("petitscours.urls")),
# Les sondages
url(r"^survey/", include(surveys_patterns)),
# Evenements
url(r"^event/", include(events_patterns)),
# Calendrier
url(r"^calendar/", include(calendar_patterns)),
# Clubs
url(r"^clubs/", include(clubs_patterns)),
# Authentification
url(
r"^cof/denied$",
TemplateView.as_view(template_name="cof-denied.html"),
name="cof-denied",
),
url(r"^cas/login$", django_cas_views.LoginView.as_view(), name="cas_login_view"),
url(r"^cas/logout$", django_cas_views.LogoutView.as_view()),
url(
r"^outsider/login$",
gestioncof_views.LoginExtView.as_view(),
name="ext_login_view",
),
url(r"^outsider/logout$", django_views.LogoutView.as_view(), {"next_page": "home"}),
url(r"^login$", gestioncof_views.login, name="cof-login"),
url(r"^logout$", gestioncof_views.logout, name="cof-logout"),
# Infos persos
url(r"^profile$", gestioncof_views.profile, name="profile"),
url(
r"^outsider/password-change$",
django_views.password_change,
name="password_change",
),
url(
r"^outsider/password-change-done$",
django_views.password_change_done,
name="password_change_done",
),
# Inscription d'un nouveau membre
url(r"^registration$", gestioncof_views.registration, name="registration"),
url(
r"^registration/clipper/(?P<login_clipper>[\w-]+)/" r"(?P<fullname>.*)$",
gestioncof_views.registration_form2,
name="clipper-registration",
),
url(
r"^registration/user/(?P<username>.+)$",
gestioncof_views.registration_form2,
name="user-registration",
),
url(
r"^registration/empty$",
gestioncof_views.registration_form2,
name="empty-registration",
),
# Autocompletion
url(
r"^autocomplete/registration$",
autocomplete,
name="cof.registration.autocomplete",
),
url(
r"^user/autocomplete$",
gestioncof_views.user_autocomplete,
name="cof-user-autocomplete",
),
# Interface admin
url(r"^admin/logout/", gestioncof_views.logout),
url(r"^admin/doc/", include("django.contrib.admindocs.urls")),
url(
r"^admin/(?P<app_label>[\d\w]+)/(?P<model_name>[\d\w]+)/csv/",
csv_views.admin_list_export,
{"fields": ["username"]},
),
url(r"^admin/", include(admin.site.urls)),
# Liens utiles du COF et du BdA
url(r"^utile_cof$", gestioncof_views.utile_cof, name="utile_cof"),
url(r"^utile_bda$", gestioncof_views.utile_bda, name="utile_bda"),
url(r"^utile_bda/bda_diff$", gestioncof_views.liste_bdadiff, name="ml_diffbda"),
url(r"^utile_cof/diff_cof$", gestioncof_views.liste_diffcof, name="ml_diffcof"),
url(
r"^utile_bda/bda_revente$",
gestioncof_views.liste_bdarevente,
name="ml_bda_revente",
),
url(r"^k-fet/", include("kfet.urls")),
url(r"^cms/", include(wagtailadmin_urls)),
url(r"^documents/", include(wagtaildocs_urls)),
2017-05-26 00:58:59 +02:00
# djconfig
url(r"^config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"),
]
if "debug_toolbar" in settings.INSTALLED_APPS:
2016-11-06 15:39:14 +01:00
import debug_toolbar
urlpatterns += [url(r"^__debug__/", include(debug_toolbar.urls))]
2016-11-06 15:39:14 +01:00
if settings.DEBUG:
# Si on est en production, MEDIA_ROOT est servi par Apache.
# 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
2018-02-03 22:34:37 +01:00
urlpatterns += i18n_patterns(
2019-01-06 00:25:41 +01:00
url(r"", include(wagtail_urls)), prefix_default_language=False
2018-02-03 22:34:37 +01:00
)