urls.py 6.09 KB
Newer Older
André Anjos's avatar
André Anjos committed
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
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :

###############################################################################
#                                                                             #
# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/           #
# Contact: beat.support@idiap.ch                                              #
#                                                                             #
# This file is part of the beat.web module of the BEAT platform.              #
#                                                                             #
# Commercial License Usage                                                    #
# Licensees holding valid commercial BEAT licenses may use this file in       #
# accordance with the terms contained in a written agreement between you      #
# and Idiap. For further information contact tto@idiap.ch                     #
#                                                                             #
# Alternatively, this file may be used under the terms of the GNU Affero      #
# Public License version 3 as published by the Free Software and appearing    #
# in the file LICENSE.AGPL included in the packaging of this file.            #
# The BEAT platform is distributed in the hope that it will be useful, but    #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  #
# or FITNESS FOR A PARTICULAR PURPOSE.                                        #
#                                                                             #
# You should have received a copy of the GNU Affero Public License along      #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/.           #
#                                                                             #
###############################################################################

from django.conf.urls import url, include
from django.conf import settings
from django.views.generic import TemplateView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

33 34
from rest_framework_swagger.views import get_swagger_view

André Anjos's avatar
André Anjos committed
35 36 37
from .ui import urls as ui_urls
from .navigation import urls as navigation_urls

Samuel GAIST's avatar
Samuel GAIST committed
38 39 40 41
try:
  from urlparse import urlparse
except ImportError:
  from urllib.parse import urlparse
André Anjos's avatar
André Anjos committed
42 43 44 45

from django.contrib import admin
admin.autodiscover()

46 47
schema_view = get_swagger_view(title='BEAT API')

André Anjos's avatar
André Anjos committed
48 49 50 51 52 53 54
# Views
unprefixed_patterns = ui_urls.urlpatterns
unprefixed_patterns += navigation_urls.urlpatterns

unprefixed_patterns += [

    url(r'^algorithms/',
Philip ABBET's avatar
Philip ABBET committed
55
        include('beat.web.algorithms.urls', namespace='algorithms'),
André Anjos's avatar
André Anjos committed
56 57 58
      ),

    url(r'^libraries/',
Philip ABBET's avatar
Philip ABBET committed
59
        include('beat.web.libraries.urls', namespace='libraries'),
André Anjos's avatar
André Anjos committed
60 61 62
      ),

    url(r'^attestations/',
Philip ABBET's avatar
Philip ABBET committed
63
        include('beat.web.attestations.urls', namespace='attestations'),
André Anjos's avatar
André Anjos committed
64 65 66
      ),

    url(r'^backend/',
Philip ABBET's avatar
Philip ABBET committed
67
        include('beat.web.backend.urls', namespace='backend'),
André Anjos's avatar
André Anjos committed
68 69 70
      ),

    url(r'^dataformats/',
Philip ABBET's avatar
Philip ABBET committed
71
        include('beat.web.dataformats.urls', namespace='dataformats'),
André Anjos's avatar
André Anjos committed
72 73 74
      ),

    url(r'^databases/',
Philip ABBET's avatar
Philip ABBET committed
75
        include('beat.web.databases.urls', namespace='databases'),
André Anjos's avatar
André Anjos committed
76 77 78
      ),

    url(r'^experiments/',
Philip ABBET's avatar
Philip ABBET committed
79
        include('beat.web.experiments.urls', namespace='experiments'),
André Anjos's avatar
André Anjos committed
80 81 82
      ),

    url(r'^search/',
Philip ABBET's avatar
Philip ABBET committed
83
        include('beat.web.search.urls', namespace='search'),
André Anjos's avatar
André Anjos committed
84 85 86
      ),

    url(r'^statistics/',
Philip ABBET's avatar
Philip ABBET committed
87
        include('beat.web.statistics.urls', namespace='statistics'),
André Anjos's avatar
André Anjos committed
88 89 90
      ),

    url(r'^toolchains/',
Philip ABBET's avatar
Philip ABBET committed
91
        include('beat.web.toolchains.urls', namespace='toolchains'),
André Anjos's avatar
André Anjos committed
92 93 94
      ),

    url(r'^teams/',
Philip ABBET's avatar
Philip ABBET committed
95
        include('beat.web.team.urls', namespace='teams'),
André Anjos's avatar
André Anjos committed
96 97 98
      ),

    url(r'^plotters/',
Philip ABBET's avatar
Philip ABBET committed
99
        include('beat.web.plotters.urls', namespace='plotters'),
André Anjos's avatar
André Anjos committed
100 101 102
      ),

    url(r'^reports/',
Philip ABBET's avatar
Philip ABBET committed
103
        include('beat.web.reports.urls', namespace='reports'),
André Anjos's avatar
André Anjos committed
104 105 106 107 108 109 110 111 112
      ),

    url(r'^accounts/',
        include('beat.web.accounts.urls', namespace='accounts'),
        ),

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

    url(r'^docs/',
113
        schema_view
André Anjos's avatar
André Anjos committed
114 115 116 117 118 119
      ),

    url(r'^activity/',
        include('actstream.urls'),
        ),

Philip ABBET's avatar
Philip ABBET committed
120
]
André Anjos's avatar
André Anjos committed
121 122 123 124 125 126


# API
unprefixed_patterns += [

    url(r'^api/v1/teams/',
Philip ABBET's avatar
Philip ABBET committed
127
        include('beat.web.team.api_urls', namespace='api_teams'),
André Anjos's avatar
André Anjos committed
128 129 130
      ),

    url(r'^api/v1/algorithms/',
Philip ABBET's avatar
Philip ABBET committed
131
        include('beat.web.algorithms.api_urls', namespace='api_algorithms'),
André Anjos's avatar
André Anjos committed
132 133 134
      ),

    url(r'^api/v1/attestations/',
Philip ABBET's avatar
Philip ABBET committed
135
        include('beat.web.attestations.api_urls', namespace='api_attestations'),
André Anjos's avatar
André Anjos committed
136 137 138
      ),

    url(r'^api/v1/backend/',
Philip ABBET's avatar
Philip ABBET committed
139
        include('beat.web.backend.api_urls', namespace='api_backend'),
André Anjos's avatar
André Anjos committed
140 141 142
      ),

    url(r'^api/v1/databases/',
Philip ABBET's avatar
Philip ABBET committed
143
        include('beat.web.databases.api_urls', namespace='api_databases'),
André Anjos's avatar
André Anjos committed
144 145 146
      ),

    url(r'^api/v1/dataformats/',
Philip ABBET's avatar
Philip ABBET committed
147
        include('beat.web.dataformats.api_urls', namespace='api_dataformats'),
André Anjos's avatar
André Anjos committed
148 149 150
      ),

    url(r'^api/v1/experiments/',
Philip ABBET's avatar
Philip ABBET committed
151
        include('beat.web.experiments.api_urls', namespace='api_experiments'),
André Anjos's avatar
André Anjos committed
152 153 154
      ),

    url(r'^api/v1/libraries/',
Philip ABBET's avatar
Philip ABBET committed
155
        include('beat.web.libraries.api_urls', namespace='api_libraries'),
André Anjos's avatar
André Anjos committed
156 157 158
      ),

    url(r'^api/v1/search/',
Philip ABBET's avatar
Philip ABBET committed
159
        include('beat.web.search.api_urls', namespace='api_search'),
André Anjos's avatar
André Anjos committed
160 161 162
      ),

    url(r'^api/v1/toolchains/',
Philip ABBET's avatar
Philip ABBET committed
163
        include('beat.web.toolchains.api_urls', namespace='api_toolchains'),
André Anjos's avatar
André Anjos committed
164 165 166
      ),

    url(r'^api/v1/plotters/',
Philip ABBET's avatar
Philip ABBET committed
167
        include('beat.web.plotters.api_urls', namespace='api_plotters'),
André Anjos's avatar
André Anjos committed
168 169 170 171 172 173
      ),

    url(r'^api/v1/reports/',
        include('beat.web.reports.api_urls', namespace='api_reports'),
        ),

174 175 176 177
    url(r'^api/v1/accounts/',
        include('beat.web.accounts.api_urls', namespace='api_accounts'),
        ),

Philip ABBET's avatar
Philip ABBET committed
178
]
André Anjos's avatar
André Anjos committed
179 180 181 182 183 184 185 186 187 188 189 190 191


# Process an eventual prefix in the URLs
parsed_url = urlparse(settings.URL_PREFIX)
if (parsed_url.path != '') and (parsed_url.path != '/'):
    urlpatterns = [
        url(r'^%s/' % parsed_url.path[1:], include(unprefixed_patterns)),
    ]
else:
    urlpatterns = unprefixed_patterns

# Static files (only working during development, when settings.DEBUG is True)
urlpatterns += staticfiles_urlpatterns()
192 193 194 195 196


# ONLY DURING THE TESTS: Custom error 500 view
if getattr(settings, 'TEST_CONFIGURATION', False):
    handler500 = 'beat.web.ui.views.empty_error500_for_tests'