1import os
2from django.conf.urls import defaults
3from django.conf import settings
4
5# The next two lines enable the admin and load each admin.py file:
6from django.contrib import admin
7admin.autodiscover()
8
9RE_PREFIX = '^' + settings.URL_PREFIX
10TKO_RE_PREFIX = '^' + settings.TKO_URL_PREFIX
11
12handler404 = 'django.views.defaults.page_not_found'
13handler500 = 'frontend.afe.views.handler500'
14
15urlpatterns = defaults.patterns(
16        '',
17        (RE_PREFIX + r'admin/', defaults.include(admin.site.urls)),
18        (RE_PREFIX, defaults.include('frontend.afe.urls')),
19        (TKO_RE_PREFIX, defaults.include('frontend.tko.urls')),
20        (RE_PREFIX + r'static/(?P<path>.*)', 'django.views.static.serve',
21         {'document_root': os.path.join(os.path.dirname(__file__), 'static')}),
22    )
23
24if os.path.exists(os.path.join(os.path.dirname(__file__),
25                               'tko', 'site_urls.py')):
26    urlpatterns += defaults.patterns(
27            '', (TKO_RE_PREFIX, defaults.include('frontend.tko.site_urls')))
28
29debug_patterns = defaults.patterns(
30        '',
31        # redirect /tko and /results to local apache server
32        (r'^(?P<path>(tko|results)/.*)$',
33         'frontend.afe.views.redirect_with_extra_data',
34         {'url': 'http://%(server_name)s/%(path)s?%(getdata)s'}),
35    )
36
37if settings.DEBUG:
38    urlpatterns += debug_patterns
39