-
Notifications
You must be signed in to change notification settings - Fork 81
/
urls.py
106 lines (99 loc) · 3.89 KB
/
urls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""
TWLight URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/ref/urls/
"""
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.admindocs import urls as admindocs
from django.contrib.auth import views as auth_views
from django.contrib.auth.decorators import login_required
from django.urls import path
from django.views.generic import TemplateView
from django.views.decorators.cache import cache_page
from TWLight.api.urls import urlpatterns as api_urls
from TWLight.applications.urls import urlpatterns as applications_urls
from TWLight.emails.views import ContactUsView
from TWLight.resources.urls import urlpatterns as partners_urls
from TWLight.resources.views import (
PartnerSuggestionView,
SuggestionDeleteView,
SuggestionUpvoteView,
)
from TWLight.users import oauth as auth
from TWLight.users.urls import urlpatterns as users_urls
from TWLight.users.views import TermsView
from TWLight.ezproxy.urls import urlpatterns as ezproxy_urls
from .views import NewHomePageView, SearchEndpointFormView
handler400 = "TWLight.views.bad_request"
urlpatterns = [
# Built-in -----------------------------------------------------------------
url(r"^admin/doc", include(admindocs)),
url(r"^admin/", admin.site.urls),
url(r"^accounts/login/", auth_views.LoginView.as_view(), name="auth_login"),
url(
r"^accounts/logout/",
auth_views.LogoutView.as_view(),
{"next_page": "/"},
name="auth_logout",
),
url(
r"^password/change/$",
auth_views.PasswordChangeView.as_view(),
{"post_change_redirect": "users:home"},
name="password_change",
),
url(
r"^password/reset/$",
auth_views.PasswordResetView.as_view(),
{"post_reset_redirect": "users:home"},
name="password_reset",
),
# Third-party --------------------------------------------------------------
url(r"^comments/", include("django_comments.urls")),
# TWLight apps -------------------------------------------------------------
# This makes our custom set language form available.
url(r"^i18n/", include("TWLight.i18n.urls")),
url(r"^api/", include((api_urls, "api"), namespace="api")),
url(r"^users/", include((users_urls, "users"), namespace="users")),
url(
r"^applications/",
include((applications_urls, "applications"), namespace="applications"),
),
url(r"^partners/", include((partners_urls, "resources"), namespace="partners")),
url(r"^ezproxy/", include((ezproxy_urls, "ezproxy"), namespace="ezproxy")),
# Other TWLight views
url(r"^oauth/login/$", auth.OAuthInitializeView.as_view(), name="oauth_login"),
url(r"^oauth/callback/$", auth.OAuthCallbackView.as_view(), name="oauth_callback"),
url(r"^terms/$", TermsView.as_view(), name="terms"),
# For partner suggestions
url(r"^suggest/$", PartnerSuggestionView.as_view(), name="suggest"),
url(
r"^suggest/(?P<pk>[0-9]+)/delete/$",
login_required(SuggestionDeleteView.as_view()),
name="suggest-delete",
),
url(
r"^suggest/(?P<pk>[0-9]+)/upvote/$",
login_required(SuggestionUpvoteView.as_view()),
name="upvote",
),
# For contact us form
url(r"^contact/$", ContactUsView.as_view(), name="contact"),
url(r"^$", NewHomePageView.as_view(), name="homepage"),
url(r"^about/$", TemplateView.as_view(template_name="about.html"), name="about"),
url(
r"^search/$",
login_required(SearchEndpointFormView.as_view()),
name="search",
),
]
# Enable debug_toolbar if configured
if (
settings.TWLIGHT_ENV == "local"
and settings.REQUIREMENTS_FILE == "debug.txt"
and settings.DEBUG
):
import debug_toolbar
urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]