urls.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_nested import routers
  10. from api_tokens.urls import router as apiTokensRouter
  11. from issues.urls import router as issuesRouter
  12. from issues.views import EventJsonView
  13. from organizations_ext.urls import router as organizationsRouter
  14. from projects.urls import router as projectsRouter
  15. from teams.urls import router as teamsRouter
  16. from users.urls import router as usersRouter
  17. from users.views import SocialAccountDisconnectView
  18. from . import social
  19. from .api import api
  20. from .views import APIRootView, health
  21. router = routers.DefaultRouter()
  22. router.registry.extend(projectsRouter.registry)
  23. router.registry.extend(issuesRouter.registry)
  24. router.registry.extend(organizationsRouter.registry)
  25. router.registry.extend(teamsRouter.registry)
  26. router.registry.extend(usersRouter.registry)
  27. router.registry.extend(apiTokensRouter.registry)
  28. if settings.BILLING_ENABLED:
  29. from djstripe_ext.urls import router as djstripeRouter
  30. router.registry.extend(djstripeRouter.registry)
  31. urlpatterns = [
  32. path("_health/", health),
  33. re_path(
  34. r"^favicon\.ico$",
  35. RedirectView.as_view(url=settings.STATIC_URL + "favicon.ico", permanent=True),
  36. ),
  37. path(
  38. "robots.txt",
  39. TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),
  40. ),
  41. path("api/", api.urls),
  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("", include("glitchtip.uptime.urls")),
  71. # What an oddball API endpoint
  72. path(
  73. "organizations/<slug:org>/issues/<int:issue>/events/<str:event>/json/",
  74. EventJsonView.as_view(),
  75. name="event_json",
  76. ),
  77. path("api/test/", include("test_api.urls")),
  78. path("rest-auth/login/", MFALoginView.as_view()),
  79. path("rest-auth/", include("dj_rest_auth.urls")),
  80. path("rest-auth/registration/", include("dj_rest_auth.registration.urls")),
  81. re_path(
  82. r"^api/socialaccounts/(?P<pk>\d+)/disconnect/$",
  83. SocialAccountDisconnectView.as_view(),
  84. name="social_account_disconnect",
  85. ),
  86. path("rest-auth/<slug:provider>/", social.MFASocialLoginView().as_view()),
  87. path(
  88. "rest-auth/<slug:provider>/connect/",
  89. social.GlitchTipSocialConnectView().as_view(),
  90. ),
  91. path("accounts/", include("allauth.urls")), # Required for allauth
  92. # These routes belong to the Angular single page app
  93. re_path(r"^$", TemplateView.as_view(template_name="index.html")),
  94. re_path(
  95. r"^(auth|login|register|(.*)/issues|(.*)/settings|(.*)/performance|(.*)/projects|(.*)/releases|organizations|profile|(.*)/uptime-monitors|accept|reset-password).*$",
  96. TemplateView.as_view(template_name="index.html"),
  97. ),
  98. # These URLS are for generating reverse urls in django, but are not really present
  99. # Change the activate_url in the confirm emails
  100. re_path(
  101. r"^profile/confirm-email/(?P<key>[-:\w]+)/$",
  102. TemplateView.as_view(),
  103. name="account_confirm_email",
  104. ),
  105. # Change the password_reset_confirm in the reset password emails
  106. re_path(
  107. 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})/$",
  108. TemplateView.as_view(),
  109. name="password_reset_confirm",
  110. ),
  111. path("accept/", include(invitation_backend().get_urls())),
  112. path("api/0/observability/", include("observability.urls")),
  113. ]
  114. if settings.BILLING_ENABLED:
  115. urlpatterns.append(path("stripe/", include("djstripe.urls", namespace="djstripe")))
  116. if settings.DEBUG_TOOLBAR:
  117. urlpatterns.append(path("__debug__/", include("debug_toolbar.urls")))
  118. if settings.DEBUG:
  119. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)