urls.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. from django.conf import settings
  2. from django.conf.urls.static import static
  3. from django.contrib import admin
  4. from django.urls import include, path, re_path
  5. from django.views.generic import TemplateView
  6. from django.views.generic.base import RedirectView
  7. from django_rest_mfa.rest_auth_helpers.views import MFALoginView
  8. from organizations.backends import invitation_backend
  9. from rest_framework import permissions
  10. from rest_framework_nested import routers
  11. from api_tokens.urls import router as apiTokensRouter
  12. from issues.urls import router as issuesRouter
  13. from issues.views import EventJsonView
  14. from organizations_ext.urls import router as organizationsRouter
  15. from projects.urls import router as projectsRouter
  16. from teams.urls import router as teamsRouter
  17. from users.urls import router as usersRouter
  18. from users.views import SocialAccountDisconnectView
  19. from . import social
  20. from .api import api
  21. from .views import APIRootView, health
  22. router = routers.DefaultRouter()
  23. router.registry.extend(projectsRouter.registry)
  24. router.registry.extend(issuesRouter.registry)
  25. router.registry.extend(organizationsRouter.registry)
  26. router.registry.extend(teamsRouter.registry)
  27. router.registry.extend(usersRouter.registry)
  28. router.registry.extend(apiTokensRouter.registry)
  29. if settings.BILLING_ENABLED:
  30. from djstripe_ext.urls import router as djstripeRouter
  31. router.registry.extend(djstripeRouter.registry)
  32. urlpatterns = [
  33. path("_health/", health),
  34. re_path(
  35. r"^favicon\.ico$",
  36. RedirectView.as_view(url=settings.STATIC_URL + "favicon.ico", permanent=True),
  37. ),
  38. path(
  39. "robots.txt",
  40. TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),
  41. ),
  42. path("api/", RedirectView.as_view(url="/profile/auth-tokens")),
  43. path("api/0/", APIRootView.as_view(), name="api-root-view"),
  44. path("api/0/", include(router.urls)),
  45. ]
  46. if "django.contrib.admin" in settings.INSTALLED_APPS:
  47. urlpatterns += [
  48. path("admin/", include("django_rest_mfa.mfa_admin.urls")),
  49. path("admin/", admin.site.urls),
  50. path("api/0/", include("glitchtip.importer.urls")),
  51. ]
  52. if settings.BILLING_ENABLED:
  53. urlpatterns += [
  54. path("api/0/", include("djstripe_ext.urls")),
  55. ]
  56. urlpatterns += [
  57. path("api/0/", include("projects.urls")),
  58. path("api/0/", include("issues.urls")),
  59. path("api/0/", include("users.urls")),
  60. path("api/0/", include("organizations_ext.urls")),
  61. path("api/0/", include("teams.urls")),
  62. path("api/0/", include("api_tokens.urls")),
  63. path("api/0/", include("files.urls")),
  64. path("api/0/", include("difs.urls")),
  65. path("api/0/", include("glitchtip.stats.urls")),
  66. path("api/0/", include("glitchtip.wizard.urls")),
  67. path("api/mfa/", include("django_rest_mfa.urls")),
  68. path("api/", include("events.urls")),
  69. path("api/embed/", include("user_reports.urls")),
  70. path("api/", api.urls),
  71. path("", include("glitchtip.uptime.urls")),
  72. # What an oddball API endpoint
  73. path(
  74. "organizations/<slug:org>/issues/<int:issue>/events/<str:event>/json/",
  75. EventJsonView.as_view(),
  76. name="event_json",
  77. ),
  78. path("api/test/", include("test_api.urls")),
  79. path("rest-auth/login/", MFALoginView.as_view()),
  80. path("rest-auth/", include("dj_rest_auth.urls")),
  81. path("rest-auth/registration/", include("dj_rest_auth.registration.urls")),
  82. re_path(
  83. r"^api/socialaccounts/(?P<pk>\d+)/disconnect/$",
  84. SocialAccountDisconnectView.as_view(),
  85. name="social_account_disconnect",
  86. ),
  87. path("rest-auth/<slug:provider>/", social.MFASocialLoginView().as_view()),
  88. path(
  89. "rest-auth/<slug:provider>/connect/",
  90. social.GlitchTipSocialConnectView().as_view(),
  91. ),
  92. path("accounts/", include("allauth.urls")), # Required for allauth
  93. # These routes belong to the Angular single page app
  94. re_path(r"^$", TemplateView.as_view(template_name="index.html")),
  95. re_path(
  96. r"^(auth|login|register|(.*)/issues|(.*)/settings|(.*)/performance|(.*)/projects|(.*)/releases|organizations|profile|(.*)/uptime-monitors|accept|reset-password).*$",
  97. TemplateView.as_view(template_name="index.html"),
  98. ),
  99. # These URLS are for generating reverse urls in django, but are not really present
  100. # Change the activate_url in the confirm emails
  101. re_path(
  102. r"^profile/confirm-email/(?P<key>[-:\w]+)/$",
  103. TemplateView.as_view(),
  104. name="account_confirm_email",
  105. ),
  106. # Change the password_reset_confirm in the reset password emails
  107. re_path(
  108. r"^reset-password/set-new-password/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,93}-[0-9A-Za-z]{1,90})/$",
  109. TemplateView.as_view(),
  110. name="password_reset_confirm",
  111. ),
  112. path("accept/", include(invitation_backend().get_urls())),
  113. path("api/0/observability/", include("observability.urls")),
  114. ]
  115. if settings.BILLING_ENABLED:
  116. urlpatterns.append(path("stripe/", include("djstripe.urls", namespace="djstripe")))
  117. if settings.DEBUG_TOOLBAR:
  118. urlpatterns.append(path("__debug__/", include("debug_toolbar.urls")))
  119. if settings.DEBUG:
  120. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)