Coverage for ivatar/urls.py: 84%
19 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-26 00:11 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-26 00:11 +0000
1# -*- coding: utf-8 -*-
2"""
3ivatar URL configuration
4"""
5from django.contrib import admin
6from django.urls import path, include, re_path
7from django.conf.urls.static import static
8from django.views.generic import TemplateView, RedirectView
9from ivatar import settings
10from .views import AvatarImageView, GravatarProxyView, StatsView
12urlpatterns = [ # pylint: disable=invalid-name
13 path("admin/", admin.site.urls),
14 path("i18n/", include("django.conf.urls.i18n")),
15 path("openid/", include("django_openid_auth.urls")),
16 path("tools/", include("ivatar.tools.urls")),
17 re_path(
18 r"avatar/(?P<digest>\w{64})", AvatarImageView.as_view(), name="avatar_view"
19 ),
20 re_path(
21 r"avatar/(?P<digest>\w{32})", AvatarImageView.as_view(), name="avatar_view"
22 ),
23 re_path(r"avatar/$", AvatarImageView.as_view(), name="avatar_view"),
24 re_path(
25 r"avatar/(?P<digest>\w*)",
26 RedirectView.as_view(url="/static/img/deadbeef.png"),
27 name="invalid_hash",
28 ),
29 re_path(
30 r"gravatarproxy/(?P<digest>\w*)",
31 GravatarProxyView.as_view(),
32 name="gravatarproxy",
33 ),
34 path(
35 "description/",
36 TemplateView.as_view(template_name="description.html"),
37 name="description",
38 ),
39 # The following two are TODO TODO TODO TODO TODO
40 path(
41 "run_your_own/",
42 TemplateView.as_view(template_name="run_your_own.html"),
43 name="run_your_own",
44 ),
45 path(
46 "features/",
47 TemplateView.as_view(template_name="features.html"),
48 name="features",
49 ),
50 path(
51 "security/",
52 TemplateView.as_view(template_name="security.html"),
53 name="security",
54 ),
55 path(
56 "privacy/", TemplateView.as_view(template_name="privacy.html"), name="privacy"
57 ),
58 path(
59 "contact/", TemplateView.as_view(template_name="contact.html"), name="contact"
60 ),
61 path("talk_to_us/", RedirectView.as_view(url="/contact"), name="talk_to_us"),
62 path("stats/", StatsView.as_view(), name="stats"),
63]
65MAINTENANCE = False
66try:
67 if settings.MAINTENANCE:
68 MAINTENANCE = True
69except Exception: # pylint: disable=bare-except
70 pass
72if MAINTENANCE:
73 urlpatterns.append(
74 path("", TemplateView.as_view(template_name="maintenance.html"), name="home")
75 )
76 urlpatterns.insert(3, path("accounts/", RedirectView.as_view(url="/")))
77else:
78 urlpatterns.append(
79 path("", TemplateView.as_view(template_name="home.html"), name="home")
80 )
81 urlpatterns.insert(3, path("accounts/", include("ivatar.ivataraccount.urls")))
83urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)