urls.py 2.24 KB
Newer Older
1
# Django Imports
2
from django.conf.urls import include, url
David Haynes's avatar
David Haynes committed
3
import django.contrib.auth.views
4
from django.contrib import admin
5
from django.conf import settings
6 7 8 9
from django.views.generic import TemplateView

# App Imports
import go.views
10

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

15
# Handle 404 and 500 errors with custom pages
David Haynes's avatar
David Haynes committed
16 17
handle404 = TemplateView.as_view(template_name="admin/404.html")
handle500 = TemplateView.as_view(template_name="admin/500.html")
18

19
# Main list of project URL's
David Haynes's avatar
David Haynes committed
20
urlpatterns = [
21
    # / - Homepage url.
David Haynes's avatar
David Haynes committed
22
    url(r'^$', go.views.index, name='index'),
23

Jean Michel Rouly's avatar
Jean Michel Rouly committed
24
    # /view/<short> - View URL data.
David Haynes's avatar
David Haynes committed
25
    url(r'^view/(?P<short>\w+)$', go.views.view, name='view'),
26

27
    # /about - About page.
28
    url(r'^about/?$', TemplateView.as_view(template_name='core/about.html'), name='about'),
29

Jean Michel Rouly's avatar
Jean Michel Rouly committed
30
    # /signup - Signup page for access.
David Haynes's avatar
David Haynes committed
31
    url(r'^signup/?$', go.views.signup, name='signup'),
Jean Michel Rouly's avatar
Jean Michel Rouly committed
32

33
    # /my - My-Links page, view and review links.
34
    url(r'^myLinks/?$', go.views.my_links, name='my_links'),
35

Jean Michel Rouly's avatar
Jean Michel Rouly committed
36
    # /delete/<short> - Delete a link, no content display.
David Haynes's avatar
David Haynes committed
37
    url(r'^delete/(?P<short>\w+)$', go.views.delete, name='delete'),
38

39
    # /registered - registration complete page
40
    url(r'^registered/?$', TemplateView.as_view(template_name='registered.html'), name='registered'),
41

42
    # /admin - Administrator interface.
David Haynes's avatar
David Haynes committed
43
    url(r'^admin/?', admin.site.urls),
44

Chris Reffett's avatar
Chris Reffett committed
45
    # /useradmin - user approval interface
David Haynes's avatar
David Haynes committed
46 47
    url(r'^useradmin/?$', go.views.useradmin, name='useradmin'),
]
48 49

# Handle authentication pages
50 51 52 53 54 55 56 57 58 59 60 61 62 63
if settings.AUTH_MODE.lower() == "ldap":
    urlpatterns += [
        # Auth pages
        url(r'^login$', django.contrib.auth.views.login, {'template_name' : 'core/login.html'}, name='go_login'),
        url(r'^logout$', django.contrib.auth.views.logout, {'next_page': '/'},
            name='go_logout'),
    ]
else:
    urlpatterns += [
        # Auth pages
        url(r'^login$', django.contrib.auth.views.login, name='go_login'),
        url(r'^logout$', django.contrib.auth.views.logout, {'next_page': '/'},
            name='go_logout'),
    ]
Jean Michel Rouly's avatar
Jean Michel Rouly committed
64

David Haynes's avatar
David Haynes committed
65
urlpatterns += [
Jean Michel Rouly's avatar
Jean Michel Rouly committed
66
    # Redirection regex.
David Haynes's avatar
David Haynes committed
67 68 69
    url(r'^(?P<short>\w+)$', go.views.redirection, name='redirection'),

]