urls.py 2.19 KB
Newer Older
David Haynes's avatar
David Haynes committed
1 2 3
"""
settings/urls.py

David Haynes's avatar
David Haynes committed
4 5
The URLs of the project and their associated view that requests are routed to.
"""
6
# Django Imports
David Haynes's avatar
David Haynes committed
7
import django.contrib.auth.views
Samuel Kebadu's avatar
Samuel Kebadu committed
8
from django.urls import path
9
from django.contrib import admin
Grady Moran's avatar
Grady Moran committed
10
from django.views.decorators.cache import cache_page
11 12 13 14
from django.views.generic import TemplateView

# App Imports
import go.views
15

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

David Haynes's avatar
David Haynes committed
20
urlpatterns = [
David Haynes's avatar
David Haynes committed
21 22
    # / - Homepage url. Cached for 1 second (this is the page you see after
    # logging in, so having it show as not logged in is strange)
Samuel Kebadu's avatar
Samuel Kebadu committed
23
    path('', cache_page(1)(go.views.index), name='index'),
24

25
    # /view/<short> - View URL data. Cached for 15 minutes
Samuel Kebadu's avatar
Samuel Kebadu committed
26
    path('view/<slug:short>', cache_page(60 * 15)(go.views.view), name='view'),
27

28
    # /about - About page. Cached for 15 minutes
Samuel Kebadu's avatar
Samuel Kebadu committed
29
    path('about',cache_page(60 * 15)(TemplateView.as_view(template_name='core/about.html')), name='about'),
30

31
    # /signup - Signup page for access. Cached for 15 minutes
Samuel Kebadu's avatar
Samuel Kebadu committed
32
    path('signup', cache_page(60 * 15)(go.views.signup), name='signup'),
Jean Michel Rouly's avatar
Jean Michel Rouly committed
33

David Haynes's avatar
David Haynes committed
34
    # /new - Create a new Go Link
Samuel Kebadu's avatar
Samuel Kebadu committed
35
    path('new', go.views.new_link, name='new_link'),
36

David Haynes's avatar
David Haynes committed
37
    # /my - My-Links page, view and review links.
Samuel Kebadu's avatar
Samuel Kebadu committed
38
    path('my', go.views.my_links, name='my_links'),
39

David Haynes's avatar
David Haynes committed
40
    # /edit/<short> - Edit link form
Samuel Kebadu's avatar
Samuel Kebadu committed
41
    path('edit/<slug:short>', go.views.edit, name='edit'),
David Haynes's avatar
David Haynes committed
42

Jean Michel Rouly's avatar
Jean Michel Rouly committed
43
    # /delete/<short> - Delete a link, no content display.
Samuel Kebadu's avatar
Samuel Kebadu committed
44
    path('delete/<slug:short>', go.views.delete, name='delete'),
45

46
    # /registered - registration complete page. Cached for 15 minutes
Samuel Kebadu's avatar
Samuel Kebadu committed
47
    path('registered', cache_page(60 * 15)(TemplateView.as_view(template_name='registered.html')), name='registered'),
48

49
    # /admin - Administrator interface.
Samuel Kebadu's avatar
Samuel Kebadu committed
50
    path('admin', admin.site.urls, name='go_admin'),
51

David Haynes's avatar
David Haynes committed
52
    # /manage - user approval interface
Samuel Kebadu's avatar
Samuel Kebadu committed
53
    path('manage', go.views.useradmin, name='useradmin'),
54

David Haynes's avatar
David Haynes committed
55
    # Authentication URLs
Samuel Kebadu's avatar
Samuel Kebadu committed
56 57
    path('login', django.contrib.auth.views.login, name='go_login'),
    path('logout', django.contrib.auth.views.logout, {'next_page': '/'}, name='go_logout'),
Jean Michel Rouly's avatar
Jean Michel Rouly committed
58 59

    # Redirection regex.
Samuel Kebadu's avatar
Samuel Kebadu committed
60
    path('<slug:short>', go.views.redirection, name='redirection'),
David Haynes's avatar
David Haynes committed
61
]