urls.py 1.29 KB
Newer Older
David Haynes's avatar
David Haynes committed
1 2 3 4 5 6
"""
settings/urls.py

The URLs of the project and their associated view that requests are routed to.
"""
# Django Imports
David Haynes's avatar
David Haynes committed
7
from django.urls import path, include, re_path
David Haynes's avatar
David Haynes committed
8 9 10 11
from django.contrib import admin

# Third Party
from rest_framework import routers
12 13 14 15
from cas import views as cas_views

# App Imports
from . import views
David Haynes's avatar
David Haynes committed
16

17 18
ROUTER = routers.DefaultRouter()
ROUTER.register(r"golinks", views.URLViewSet, base_name="golinks")
David Haynes's avatar
David Haynes committed
19 20 21 22 23 24 25

# This function attempts to import an admin module in each installed
# application. Such modules are expected to register models with the admin.
admin.autodiscover()

urlpatterns = [
    # Root API URL
26
    path("api/", include(ROUTER.urls)),
David Haynes's avatar
David Haynes committed
27
    # Authentication URLs
28
    path("auth/", include("rest_framework.urls")),
David Haynes's avatar
David Haynes committed
29 30
    path("auth/login/", cas_views.login, name="cas_login"),
    path("auth/logout/", cas_views.logout, name="cas_logout"),
31
    path("auth/token/", views.CustomAuthToken.as_view()),
David Haynes's avatar
David Haynes committed
32
    path("auth/status/", views.GetSessionInfo.as_view()),
33 34
    # /admin - Administrator interface.
    path("admin/", admin.site.urls, name="go_admin"),
David Haynes's avatar
David Haynes committed
35 36 37 38 39 40 41
    # Redirection regex.
    re_path(
        r"^(?P<short>([\U00010000-\U0010ffff][\U0000200D]?)+)$",
        views.redirection,
        name="redirection",
    ),
    re_path(r"^(?P<short>[-\w]+)$", views.redirection, name="redirection"),
David Haynes's avatar
David Haynes committed
42
]