urls.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 organizations.backends import invitation_backend
  8. from .api.api import api
  9. from .views import health
  10. urlpatterns = [
  11. path("_health/", health),
  12. re_path(
  13. r"^favicon\.ico$",
  14. RedirectView.as_view(url=settings.STATIC_URL + "favicon.ico", permanent=True),
  15. ),
  16. path(
  17. "robots.txt",
  18. TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),
  19. ),
  20. path("api/", RedirectView.as_view(url="/profile/auth-tokens")),
  21. # OSS Sentry compat - redirect the non-api prefix url to the more typical api prefix
  22. path(
  23. "organizations/<slug:organization_slug>/issues/<int:issue_id>/events/<event_id>/json/",
  24. RedirectView.as_view(
  25. url="/api/0/organizations/%(organization_slug)s/issues/%(issue_id)s/events/%(event_id)s/json/",
  26. ),
  27. ),
  28. path("api/", api.urls),
  29. ]
  30. if "django.contrib.admin" in settings.INSTALLED_APPS:
  31. urlpatterns += [
  32. path("admin/", admin.site.urls),
  33. ]
  34. urlpatterns += [
  35. path("", include("apps.uptime.urls")),
  36. path("api/test/", include("test_api.urls")),
  37. path("accounts/", include("allauth.urls")),
  38. path("_allauth/", include("allauth.headless.urls")),
  39. # These routes belong to the Angular single page app
  40. re_path(r"^$", TemplateView.as_view(template_name="index.html")),
  41. re_path(
  42. r"^(auth|login|register|(.*)/issues|(.*)/settings|(.*)/performance|(.*)/projects|(.*)/releases|organizations|profile|(.*)/uptime-monitors|accept|reset-password).*$",
  43. TemplateView.as_view(template_name="index.html"),
  44. ),
  45. path("accept/", include(invitation_backend().get_urls())),
  46. ]
  47. if settings.BILLING_ENABLED:
  48. urlpatterns.append(path("stripe/", include("djstripe.urls", namespace="djstripe")))
  49. if settings.DEBUG_TOOLBAR:
  50. urlpatterns.append(path("__debug__/", include("debug_toolbar.urls")))
  51. if settings.DEBUG:
  52. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)