Coverage for ivatar/urls.py: 88%

16 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-20 05:10 +0000

1""" 

2ivatar URL configuration 

3""" 

4 

5import contextlib 

6from django.contrib import admin 

7from django.urls import path, include, re_path 

8from django.conf.urls.static import static 

9from django.views.generic import TemplateView, RedirectView 

10from django.conf import settings 

11from .views import AvatarImageView, StatsView, PerfTestView 

12from .views import GravatarProxyView, BlueskyProxyView, DeploymentVersionView 

13 

14urlpatterns = [ # pylint: disable=invalid-name 

15 path("perf-test/", PerfTestView.as_view(), name="perf_test"), 

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

17 path("i18n/", include("django.conf.urls.i18n")), 

18 path("openid/", include("django_openid_auth.urls")), 

19 path("auth/", include("social_django.urls", namespace="social")), 

20 path("tools/", include("ivatar.tools.urls")), 

21 re_path( 

22 r"avatar/(?P<digest>\w{64})", AvatarImageView.as_view(), name="avatar_view" 

23 ), 

24 re_path( 

25 r"avatar/(?P<digest>\w{32})", AvatarImageView.as_view(), name="avatar_view" 

26 ), 

27 re_path(r"avatar/$", AvatarImageView.as_view(), name="avatar_view"), 

28 re_path( 

29 r"avatar/(?P<digest>\w*)", 

30 RedirectView.as_view(url="/static/img/deadbeef.png"), 

31 name="invalid_hash", 

32 ), 

33 re_path( 

34 r"gravatarproxy/(?P<digest>\w*)", 

35 GravatarProxyView.as_view(), 

36 name="gravatarproxy", 

37 ), 

38 re_path( 

39 r"blueskyproxy/(?P<digest>\w*)", 

40 BlueskyProxyView.as_view(), 

41 name="blueskyproxy", 

42 ), 

43 path( 

44 "description/", 

45 TemplateView.as_view(template_name="description.html"), 

46 name="description", 

47 ), 

48 # The following two are TODO TODO TODO TODO TODO 

49 path( 

50 "run_your_own/", 

51 TemplateView.as_view(template_name="run_your_own.html"), 

52 name="run_your_own", 

53 ), 

54 path( 

55 "features/", 

56 TemplateView.as_view(template_name="features.html"), 

57 name="features", 

58 ), 

59 path( 

60 "security/", 

61 TemplateView.as_view(template_name="security.html"), 

62 name="security", 

63 ), 

64 path( 

65 "privacy/", TemplateView.as_view(template_name="privacy.html"), name="privacy" 

66 ), 

67 path( 

68 "contact/", TemplateView.as_view(template_name="contact.html"), name="contact" 

69 ), 

70 path("talk_to_us/", RedirectView.as_view(url="/contact"), name="talk_to_us"), 

71 path("stats/", StatsView.as_view(), name="stats"), 

72 path( 

73 "deployment/version/", 

74 DeploymentVersionView.as_view(), 

75 name="deployment_version", 

76 ), 

77 path( 

78 "version/", 

79 DeploymentVersionView.as_view(), 

80 name="version", 

81 ), 

82] 

83 

84MAINTENANCE = getattr(settings, "MAINTENANCE", False) 

85if MAINTENANCE: 

86 urlpatterns.append( 

87 path("", TemplateView.as_view(template_name="maintenance.html"), name="home") 

88 ) 

89 urlpatterns.insert(3, path("accounts/", RedirectView.as_view(url="/"))) 

90else: 

91 urlpatterns.append( 

92 path("", TemplateView.as_view(template_name="home.html"), name="home") 

93 ) 

94 urlpatterns.insert(3, path("accounts/", include("ivatar.ivataraccount.urls"))) 

95 

96urlpatterns += static( 

97 getattr(settings, "STATIC_URL", "/static/"), 

98 document_root=getattr(settings, "STATIC_ROOT", "/tmp/static"), 

99)