1#!/usr/bin/env python3
 2
 3"""Standard Django file to map misc URLs to functions."""
 4
 5from django.urls import path
 6from django.urls import re_path
 7from django.views.generic import TemplateView
 8from django.views.generic import RedirectView
 9
10from chart.project import settings
11import chart.web.views
12import chart.web.userinfo
13import chart.web.views_sysinfo
14
15app_name = 'web'
16
17urlpatterns = [
18    # Main CSS file
19    path('chart.css',
20        chart.web.views.css,
21        name='css'),
22
23    # Javascript support
24    path('user/js.js',
25        TemplateView.as_view(template_name='web/userinfo.js',
26                             content_type='text/javascript'),
27        name='userinfo/js'),
28]
29
30# some URLs are not available on the EPP
31if not settings.WEB_PROXY and settings.LOCKDOWN_LOGIN_ALLOWED:
32    urlpatterns += [
33        # log in
34        path('login',
35            chart.web.views.login,
36            name='user/login'),
37
38        # User management - log out
39        path('logout',
40            chart.web.views.logout,
41            name='user/logout'),
42
43        # Let admins re-login as someone else
44        path('user/switch_user',
45            chart.web.userinfo.switch_user,
46            name='userinfo/switch_user'),
47
48        # Send test email
49        path('user/test_email',
50            chart.web.userinfo.test_email,
51            name='userinfo/test_email'),
52
53        # Ajax save info
54        path('user/save',
55            chart.web.userinfo.save,
56            name='userinfo/save'),
57
58        # Test throw exception
59        path('throw',
60            chart.web.views.throw,
61            name='throw'),
62
63        # System info
64        path('sysinfo',
65            chart.web.views_sysinfo.index,
66            name='sysinfo/index'),
67
68    ]
69
70if not settings.LOCKDOWN_RESTRICTED_ACCESS:
71    urlpatterns += [
72        # User info page
73        re_path(r'user(/(?P<user_id>[0-9]+))?$',
74            chart.web.userinfo.index,
75            name='userinfo/index'),
76]