forked from dandi/dandi-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurls.py
151 lines (134 loc) · 4.82 KB
/
urls.py
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
from __future__ import annotations
from django.conf import settings
from django.contrib import admin
from django.urls import include, path, re_path, register_converter
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
from rest_framework_extensions.routers import ExtendedSimpleRouter
from dandiapi.api.views import (
AssetViewSet,
DandisetViewSet,
DashboardView,
NestedAssetViewSet,
VersionViewSet,
auth_token_view,
authorize_view,
blob_read_view,
info_view,
presigned_cookie_s3_cloudfront_view,
mailchimp_csv_view,
robots_txt_view,
root_content_view,
stats_view,
upload_complete_view,
upload_initialize_view,
upload_validate_view,
user_approval_view,
user_questionnaire_form_view,
users_me_view,
users_search_view,
)
from dandiapi.search.views import search_genotypes, search_species
from dandiapi.zarr.views import ZarrViewSet
from dandiapi.api.views.auth import ExternalAPIViewset
router = ExtendedSimpleRouter()
(
router.register(r'dandisets', DandisetViewSet, basename='dandiset')
.register(
r'versions',
VersionViewSet,
basename='version',
parents_query_lookups=[f'dandiset__{DandisetViewSet.lookup_field}'],
)
.register(
r'assets',
NestedAssetViewSet,
basename='nested-asset',
parents_query_lookups=[
f'versions__dandiset__{DandisetViewSet.lookup_field}',
f'versions__{VersionViewSet.lookup_field}',
],
)
)
router.register('assets', AssetViewSet, basename='asset')
router.register('zarr', ZarrViewSet, basename='zarr')
router.register(r'external-api', ExternalAPIViewset, basename='external-api')
schema_view = get_schema_view(
openapi.Info(
title='DANDI Archive',
default_version='v1',
description='The BRAIN Initiative archive for publishing and sharing '
'cellular neurophysiology data',
),
public=True,
permission_classes=(permissions.AllowAny,),
)
class DandisetIDConverter:
regex = r'\d{6}'
def to_python(self, value):
return value
def to_url(self, value):
return value
register_converter(DandisetIDConverter, 'dandiset_id')
urlpatterns = [
path('', root_content_view),
path('robots.txt', robots_txt_view, name='robots_txt'),
path('api/', include(router.urls)),
path('api/auth/token/', auth_token_view, name='auth-token'),
path('api/stats/', stats_view),
path('api/info/', info_view),
path('api/blobs/digest/', blob_read_view, name='blob-read'),
path('api/uploads/initialize/', upload_initialize_view, name='upload-initialize'),
re_path(
r'api/uploads/(?P<upload_id>[0-9a-f\-]{36})/complete/',
upload_complete_view,
name='upload-complete',
),
re_path(
r'^api/uploads/(?P<upload_id>[0-9a-f\-]{36})/validate/$',
upload_validate_view,
name='upload-validate',
),
path('api/users/me/', users_me_view),
path('api/users/search/', users_search_view),
re_path(
r'^api/users/questionnaire-form/$', user_questionnaire_form_view, name='user-questionnaire'
),
path(
'api/permissions/s3/',
presigned_cookie_s3_cloudfront_view,
name='presigned_cookie_s3_cloudfront'
),
re_path(
r'^api/permissions/s3/(?P<asset_path>.*)$',
presigned_cookie_s3_cloudfront_view,
name='presigned_cookie_s3_cloudfront'
),
path('api/search/genotypes/', search_genotypes),
path('api/search/species/', search_species),
path('api/permissions/s3/', presigned_cookie_s3_cloudfront_view),
path('admin/', admin.site.urls),
path('dashboard/', DashboardView.as_view(), name='dashboard-index'),
path('dashboard/user/<str:username>/', user_approval_view, name='user-approval'),
path('dashboard/mailchimp/', mailchimp_csv_view, name='mailchimp-csv'),
# this url overrides the authorize url in oauth2_provider.urls to
# support our user signup workflow
re_path(r'^oauth/authorize/$', authorize_view, name='authorize'),
path('oauth/', include('oauth2_provider.urls', namespace='oauth2_provider')),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
if settings.ENABLE_GITHUB_OAUTH:
# Include github oauth endpoints only
urlpatterns.append(
path('accounts/', include('allauth.socialaccount.providers.github.urls')),
)
else:
# Include "account" endpoints only (i.e. endpoints needed for username/password login flow)
urlpatterns.append(
path('accounts/', include('allauth.account.urls')),
)
if settings.DEBUG:
import debug_toolbar
urlpatterns = [path('__debug__/', include(debug_toolbar.urls)), *urlpatterns]