gestioCOF/cof/urls.py
Aurélien Delobelle 05eeb6a25c core -- Install django-allauth-ens
Refer to allauth doc for an accurate features list:
  http://django-allauth.readthedocs.io/en/latest/

Users can now change their password, ask for a password reset, or set
one if they don't have one.

In particular, it allows users whose account has been created via a
clipper authentication to configure a password before losing their
clipper. Even if they have already lost it, they are able to get one
using the "Reset password" functionality.

Allauth multiple emails management is deactivated. Requests to the
related url redirect to the home page.

All the login and logout views are replaced by the allauth' ones. It
also concerns the Django and Wagtail admin sites.

Note that users are no longer logged out of the clipper CAS server when
they authenticated via this server. Instead a message suggests the user
to disconnect.

Clipper connections and `login_clipper`
---------------------------------------

- Non-empty `login_clipper` are now unique among `CofProfile` instances.
- They are created once for users with a non-empty 'login_clipper' (with
the data migration 0014_create_clipper_connections).
- The `login_clipper` of CofProfile instances are sync with their
clipper connections:
    * `CofProfile.sync_clipper_connections` method updates the
connections based on `login_clipper`.
    * Signals receivers `sync_clipper…` update `login_clipper` based on
connections creations/updates/deletions.

Misc
----

- Add NullCharField (model field) which allows to use `unique=True` on
CharField (even with empty strings).
- Parts of kfet mixins for TestCase are now in shared.tests.testcase,
  as they are used elsewhere than in the kfet app.
2018-10-21 17:09:12 +02:00

141 lines
4.4 KiB
Python

"""
Fichier principal de configuration des urls du projet GestioCOF
"""
from allauth_ens.views import capture_login, capture_logout
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import RedirectView
from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailcore import urls as wagtail_urls
from wagtail.wagtaildocs 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,
petitcours_patterns,
surveys_patterns,
)
admin.autodiscover()
redirect_to_home = RedirectView.as_view(pattern_name="home")
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
url(r"^petitcours/", include(petitcours_patterns)),
# 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)),
# 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",
),
# 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")),
# djconfig
url(r"^config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"),
]
# Admin site
admin_urls = [
# Replace the login and logout views with allauth ones.
url(r"^login/", capture_login),
url(r"^logout/", capture_logout),
url(r"^doc/", include("django.contrib.admindocs.urls")),
url(
r"^(?P<app_label>[\d\w]+)/(?P<model_name>[\d\w]+)/csv/",
csv_views.admin_list_export,
{"fields": ["username"]},
),
url(r"^", include(admin.site.urls)),
]
urlpatterns += [url(r"^admin/", include(admin_urls))]
# Profile urls.
# https://django-allauth.readthedocs.io/en/latest/
profile_urls = [
url(r"^edition/$", gestioncof_views.profile, name="profile.edit"),
# allauth urls
# Multiple emails management is unused.
url(r"^email/", redirect_to_home),
url(r"^", include("allauth.urls")),
]
urlpatterns += [url(r"^profil/", include(profile_urls))]
if "debug_toolbar" in settings.INSTALLED_APPS:
import debug_toolbar
urlpatterns += [url(r"^__debug__/", include(debug_toolbar.urls))]
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)
cms_urls = [
# Replace Wagtail login and logout views with allauth ones.
url(r"^cms/login/", capture_login),
url(r"^cms/logout/", capture_logout),
# Wagtail admin.
url(r"^cms/", include(wagtailadmin_urls)),
url(r"^documents/", include(wagtaildocs_urls)),
# Wagtail serves all uncatched requests.
url(r"", include(wagtail_urls)),
]
urlpatterns += cms_urls