Coverage for website/thaliawebsite/urls.py: 100.00%

35 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2025-08-14 10:31 +0000

1"""Thalia's root URL Configuration. 

2 

3The ``urlpatterns`` list routes URLs to views. For more information please see: 

4https://docs.djangoproject.com/en/dev/topics/http/urls/ 

5 

6Examples: 

7* Function views 

8 

9 1. Add an import: ``from my_app import views`` 

10 2. Add a URL to ``urlpatterns``: ``path('', views.home, name='home')`` 

11 

12* Class-based views 

13 

14 1. Add an import: ``from other_app.views import Home`` 

15 2. Add a URL to urlpatterns: ``path('', Home.as_view(), name='home')`` 

16 

17* Including another URLconf 

18 

19 1. Import the ``include()`` function:: 

20 

21 from django.conf.urls import url, include 

22 

23 2. Add a URL to urlpatterns: ``path('blog/', include('blog.urls'))`` 

24""" 

25 

26import os.path 

27 

28from django.conf import settings 

29from django.conf.urls import include 

30from django.conf.urls.static import static 

31from django.contrib import admin 

32from django.contrib.auth import views as auth_views 

33from django.contrib.sitemaps.views import sitemap 

34from django.urls import path, re_path 

35from django.views.generic.base import TemplateView 

36 

37import debug_toolbar 

38from oauth2_provider.urls import base_urlpatterns 

39from oauth2_provider.views import ( 

40 AuthorizedTokenDeleteView, 

41 AuthorizedTokensListView, 

42 ConnectDiscoveryInfoView, 

43 JwksInfoView, 

44 UserInfoView, 

45) 

46from two_factor.urls import urlpatterns as tf_urls 

47 

48from activemembers.sitemaps import sitemap as activemembers_sitemap 

49from documents.sitemaps import sitemap as documents_sitemap 

50from education.sitemaps import sitemap as education_sitemap 

51from events.sitemaps import sitemap as events_sitemap 

52from members.sitemaps import sitemap as members_sitemap 

53from partners.sitemaps import sitemap as partners_sitemap 

54from singlepages.sitemaps import sitemap as singlepages_sitemap 

55from thabloid.sitemaps import sitemap as thabloid_sitemap 

56from thaliawebsite.views import ( 

57 IndexView, 

58 LogoutView, 

59 RateLimitedLoginView, 

60 RateLimitedPasswordResetView, 

61 TestCrashView, 

62 admin_unauthorized_view, 

63) 

64from utils.media.views import private_media 

65 

66from .sitemaps import StaticViewSitemap 

67 

68__all__ = ["urlpatterns"] 

69 

70THALIA_SITEMAP = { 

71 "main-static": StaticViewSitemap, 

72} 

73THALIA_SITEMAP.update(activemembers_sitemap) 

74THALIA_SITEMAP.update(members_sitemap) 

75THALIA_SITEMAP.update(documents_sitemap) 

76THALIA_SITEMAP.update(thabloid_sitemap) 

77THALIA_SITEMAP.update(partners_sitemap) 

78THALIA_SITEMAP.update(education_sitemap) 

79THALIA_SITEMAP.update(events_sitemap) 

80THALIA_SITEMAP.update(singlepages_sitemap) 

81 

82urlpatterns = [ 

83 path( 

84 "admin/login/", 

85 admin_unauthorized_view, 

86 name="login-redirect", 

87 ), 

88 path("admin/", admin.site.urls), 

89 path("", IndexView.as_view(), name="index"), 

90 # Default helpers 

91 path( 

92 "", 

93 include( 

94 ( 

95 [ 

96 path( 

97 "user/oauth/", 

98 include( 

99 base_urlpatterns 

100 + [ 

101 path( 

102 "authorised-apps/", 

103 AuthorizedTokensListView.as_view(), 

104 name="authorized-token-list", 

105 ), 

106 path( 

107 "authorised-apps/<int:pk>/delete/", 

108 AuthorizedTokenDeleteView.as_view(), 

109 name="authorized-token-delete", 

110 ), 

111 path( 

112 "keys/", 

113 JwksInfoView.as_view(), 

114 name="jwks-info", 

115 ), 

116 path( 

117 "info/", 

118 UserInfoView.as_view(), 

119 name="user-info", 

120 ), 

121 ] 

122 ), 

123 ), 

124 path( 

125 ".well-known/openid-configuration/", 

126 ConnectDiscoveryInfoView.as_view(), 

127 name="oidc-connect-discovery-info", 

128 ), 

129 ], 

130 "oauth2_provider", 

131 ), 

132 namespace="oauth2_provider", 

133 ), 

134 ), 

135 path( 

136 "user/", 

137 include( 

138 [ 

139 path( 

140 "password_change/", 

141 auth_views.PasswordChangeView.as_view(), 

142 name="password_change", 

143 ), 

144 path( 

145 "password_change/done/", 

146 auth_views.PasswordChangeDoneView.as_view(), 

147 name="password_change_done", 

148 ), 

149 path( 

150 "password_reset/", 

151 auth_views.PasswordResetView.as_view(), 

152 name="password_reset", 

153 ), 

154 path( 

155 "password_reset/done/", 

156 auth_views.PasswordResetDoneView.as_view(), 

157 name="password_reset_done", 

158 ), 

159 path( 

160 "reset/<uidb64>/<token>/", 

161 auth_views.PasswordResetConfirmView.as_view(), 

162 name="password_reset_confirm", 

163 ), 

164 path( 

165 "reset/done/", 

166 auth_views.PasswordResetCompleteView.as_view(), 

167 name="password_reset_complete", 

168 ), 

169 path( 

170 "account/login/", 

171 RateLimitedLoginView.as_view(), 

172 name="login", 

173 ), 

174 path( 

175 "logout/", 

176 LogoutView.as_view(), 

177 name="logout", 

178 ), 

179 path( 

180 "password_reset/", 

181 RateLimitedPasswordResetView.as_view(), 

182 name="password_reset", 

183 ), 

184 path("", include(tf_urls)), 

185 path( 

186 "account/two_factor/help/", 

187 TemplateView.as_view(template_name="two_factor/help.html"), 

188 ), 

189 ] 

190 ), 

191 ), 

192 # Apps 

193 path("", include("singlepages.urls")), 

194 path("", include("merchandise.urls")), 

195 path("", include("thabloid.urls")), 

196 path("", include("registrations.urls")), 

197 path("", include("newsletters.urls")), 

198 path("", include("announcements.urls")), 

199 path("", include("pushnotifications.urls")), 

200 path("", include("facedetection.urls")), 

201 path("", include("photos.urls")), 

202 path("", include("members.urls")), 

203 path("", include("payments.urls")), 

204 path("", include("education.urls")), 

205 path("", include("activemembers.urls")), 

206 path("", include("documents.urls")), 

207 path("", include("events.urls")), 

208 path("", include("pizzas.urls")), 

209 path("", include("partners.urls")), 

210 path("", include("sales.urls")), 

211 path("api/", include("thaliawebsite.api.urls")), 

212 # Sitemap 

213 path( 

214 "sitemap.xml", 

215 sitemap, 

216 {"sitemaps": THALIA_SITEMAP}, 

217 name="django.contrib.sitemaps.views.sitemap", 

218 ), 

219 # Dependencies 

220 path("tinymce/", include("tinymce.urls")), 

221 path("__debug__/", include(debug_toolbar.urls)), 

222 # Provide something to test error handling. Limited to admins. 

223 path("crash/", TestCrashView.as_view()), 

224 # Custom media paths 

225 re_path( 

226 r"^media/private/(?P<request_path>.*)$", private_media, name="private-media" 

227 ), 

228 path("", include("shortlinks.urls")), 

229 re_path(r"^fp/", include("django_drf_filepond.urls")), 

230] + static( 

231 settings.PUBLIC_MEDIA_URL, 

232 document_root=os.path.join(settings.MEDIA_ROOT, settings.PUBLIC_MEDIA_LOCATION), 

233)