urls.py 1.68 KB
Newer Older
David Haynes's avatar
David Haynes committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
"""
settings/urls.py

The URLs of the project and their associated view that requests are routed to.
"""
# Django Imports
from django.urls import path, re_path, include
from django.contrib import admin
from django.views.decorators.cache import cache_page
from django.views.generic import TemplateView

# App Imports
from . import views
from cas import views as cas_views

# Third Party
from rest_framework import routers

router = routers.DefaultRouter()
David Haynes's avatar
David Haynes committed
20
router.register(r"golinks", views.URLViewSet, base_name="golinks")
David Haynes's avatar
David Haynes committed
21 22 23 24 25 26 27

# 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
28
    path("api/", include(router.urls)),
David Haynes's avatar
David Haynes committed
29
    # Authentication URLs
David Haynes's avatar
David Haynes committed
30 31
    path("auth/login/", cas_views.login, name="cas_login"),
    path("auth/logout/", cas_views.logout, name="cas_logout"),
David Haynes's avatar
David Haynes committed
32
    # /admin - Administrator interface.
David Haynes's avatar
David Haynes committed
33 34 35 36 37 38 39 40 41 42 43 44 45
    path("admin/", admin.site.urls, name="go_admin"),
    path("auth/", include("rest_framework.urls")),
    path("auth/token/", views.CustomAuthToken.as_view())
    #     # /view/<short> - View URL data. Cached for 15 minutes
    #     re_path(r'^view/(?P<short>([\U00010000-\U0010ffff][\U0000200D]?)+)$',
    #             cache_page(60 * 15)(go.views.view), name='view'),
    #     re_path(r'^view/(?P<short>[-\w]+)$',
    #             cache_page(60 * 15)(go.views.view), name='view'),
    #     # Redirection regex.
    #     re_path(r'^(?P<short>([\U00010000-\U0010ffff][\U0000200D]?)+)$',
    #             go.views.redirection, name='redirection'),
    #     re_path(r'^(?P<short>[-\w]+)$',
    #             go.views.redirection, name='redirection'),
David Haynes's avatar
David Haynes committed
46
]