aboutsummaryrefslogtreecommitdiff
path: root/urls.py
blob: 99ead13ff244c5fb67b773822512bcf42c152898 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from django.conf import settings
from django.views.generic import RedirectView

try:
    from django.conf.urls.defaults import patterns, include, url
except:
    # django >= 1.6
    from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns(
    '',
    url(r'^admin/', include(admin.site.urls)),

    # Use "linaro-openid" to allow peaceful coexistence of both
    # python-apache-openid and django-openid authentication on the
    # same server.  When we get rid of apache openid protection,
    # we can go back to using just "openid" here.
    url(r'^linaro-openid/', include('django_openid_auth.urls')),
    url(r'^login/?$',
        RedirectView.as_view(url='/linaro-openid/login/', permanent=True)),
    url(r'^logout/?$', 'django.contrib.auth.views.logout'),

    # Handle JS libs and CSS.
    url(r'^js/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.JS_PATH}),
    url(r'^css/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.CSS_PATH}),

    # The license page...
    url(r'^license$',
        'license_protected_downloads.views.show_license',
        name='show_license'),

    # Exceptions redirected to root...
    url(r'^license',
        'license_protected_downloads.views.redirect_to_root',
        name='redirect_to_root'),

    # Accept the license
    url(r'^accept-license',
        'license_protected_downloads.views.accept_license',
        name='accept_license'),

    # Recursively get files for rendering (async calls accepted only).
    url(r'^get-textile-files',
        'license_protected_downloads.views.get_textile_files',
        name='get_textile_files'),

    url(r'^api/ls/(?P<path>.*)$',
        'license_protected_downloads.api.v1.list_files_api'),

    url(r'^api/license/(?P<path>.*)$',
        'license_protected_downloads.api.v1.get_license_api'),

    url(r'^api/v2/token/(?P<token>.*)$',
        'license_protected_downloads.api.v2.token'),

    url(r'^api/v2/publish/(?P<path>.*)$',
        'license_protected_downloads.api.v2.publish'),

    url(r'^api/v2/link_latest/(?P<path>.*)$',
        'license_protected_downloads.api.v2.link_latest'),

    url(r'^api/v3/token/(?P<token>.*)$',
        'license_protected_downloads.api.v3.token'),
    url(r'^api/v3/publish/(?P<path>.*)$',
        'license_protected_downloads.api.v3.publish'),
    url(r'^api/v3/link_latest/(?P<path>.*)$',
        'license_protected_downloads.api.v3.link_latest'),
)

if settings.TRACK_DOWNLOAD_STATS:
    urlpatterns += patterns(
        '',
        url(r'^reports/$',
            'license_protected_downloads.views.reports'),

        url(r'^reports/(?P<year_month>\d{4}\.\d{2})/downloads/$',
            'license_protected_downloads.views.reports_month_downloads'),
        url(r'^reports/(?P<year_month>\d{4}\.\d{2})/downloads(?P<name>/.*)',
            'license_protected_downloads.views.reports_month_file_downloads'),
        url(r'^reports/(?P<year_month>\d{4}\.\d{2})/country/$',
            'license_protected_downloads.views.reports_month_country'),
        url(r'^reports/(?P<year_month>\d{4}\.\d{2})/region/$',
            'license_protected_downloads.views.reports_month_region'),
        url(r'^reports/(?P<year_month>\d{4}\.\d{2})/country/(?P<country>.*)/',
            'license_protected_downloads.views.reports_month_country_details'),
        url(r'^reports/(?P<year_month>\d{4}\.\d{2})/region/(?P<region>.*)/',
            'license_protected_downloads.views.reports_month_region_details'),
    )

urlpatterns += patterns(
    '',
    # Catch-all. We always return a file (or try to) if it exists.
    # This handler does that.
    url(r'(?P<path>.*)', 'license_protected_downloads.views.file_server'),
)

handler500 = 'license_protected_downloads.views.error_view'