urls.py 1.99 KB
Newer Older
1 2
# -*- encoding: utf-8 -*-

3
from django.conf.urls import include, url
4
from intranet import settings
5
import django.contrib.auth.views
6
from django.views.decorators.debug import sensitive_post_parameters
7 8
from intranet.views import accueil, surlogin, surlogout
import bw_comp
9

10 11 12
from django.contrib import admin
admin.autodiscover()

13
if settings.CAS_ENABLED:
14
    from django_cas_ng.signals import cas_user_authenticated
15
    from intranet.login import post_cas_login
16
    cas_user_authenticated.connect(post_cas_login)
17
    from django_cas_ng.views import login, logout
18 19
    login_url = url(r'^login$', login, name="login")
    logout_url = url(r'^logout$', logout, name="logout")
20
else:
21 22 23
    login_view = django.contrib.auth.views.login
    login_view = sensitive_post_parameters('password')(login_view)
    login_url = url('^login', login_view, {'template_name': 'login.html'}, name="login")
24
    #login_url = url('^login', protect(django.contrib.auth.views.login), {'template_name': 'login.html'}, name="login")
25
    logout_url = url('^logout', django.contrib.auth.views.logout_then_login, name ="logout")
26

27
urlpatterns = [
28
    # Les pages existantes
29 30 31
    url('^$', accueil, name='index'),
    url('^surlogin$', surlogin, name='surlogin'),
    url('^surlogout$', surlogout, name='surlogout'),
32
    # Pages de login
33 34
    login_url,
    logout_url,
35 36
    url(r'^admin/', include(admin.site.urls)),
    #(r'^heartbeat$', bw_comp.heartbeat.view),
37
    url(r'^i18n/', include('django.conf.urls.i18n')),
38
]
39

40
for app in settings.INTRANET_APPS:
41 42
    app_name = app["name"]
    module = app.get('module', app_name)
43
    urlpatterns += [url('^%s/' % app_name, include('%s.urls' % module,
44
                                                       namespace = app_name,
45
                                                       app_name = app_name))]
46

47 48 49 50
# Pour une raison inconnue, ces valeurs par défaut ne sont pas définies ...
handler404='django.views.defaults.page_not_found'
handler403='django.views.defaults.permission_denied'
handler500='django.views.defaults.server_error'