-
Notifications
You must be signed in to change notification settings - Fork 36
/
urls.py
145 lines (132 loc) · 5.25 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
"""First entry point to define URLs."""
from django.conf import settings
from django.conf.urls import include
from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.sites.models import Site
from django.urls import path, re_path
from django.utils.translation import gettext
from django.views.decorators.cache import cache_page
from django.views.generic import TemplateView
from django.views.i18n import JavaScriptCatalog
from drf_yasg import openapi
from drf_yasg.renderers import SwaggerUIRenderer
from drf_yasg.views import get_schema_view
from rest_framework import permissions
import ontask
from ontask import models
from ontask.core import views
from ontask.dataops import pandas
from ontask.templatetags.ontask_tags import ontask_version
api_description = gettext(
'The OnTask API offers functionality to manipulate workflows, tables '
+ 'and logs. The interface provides CRUD operations over these '
+ 'objects.')
SwaggerUIRenderer.template = 'api_ui.html'
schema_view = get_schema_view(
openapi.Info(
title='OnTask API',
default_version=ontask.get_version(),
description=api_description),
public=True,
permission_classes=[permissions.AllowAny])
urlpatterns = [
# Home Page!
path('', views.HomeView.as_view(), name='home'),
path('', include('ontask.accounts.urls', namespace='accounts')),
path('lti_entry', views.LTIEntryView.as_view(), name='lti_entry'),
path('not_authorized', views.HomeView.as_view(), name='not_authorized'),
path(
'accessibility',
TemplateView.as_view(template_name='accessibility-statement.html'),
name='accessibility'),
path(
'under_construction',
TemplateView.as_view(template_name='under_construction.html'),
name='under_construction'),
path('users', include('ontask.profiles.urls', namespace='profiles')),
path('ota', admin.site.urls),
path('trck', views.TrackView.as_view(), name='trck'),
path('keep_alive', views.KeepAliveView.as_view(), name='keep_alive'),
path('workflow/', include('ontask.workflow.urls', namespace='workflow')),
path('column/', include('ontask.column.urls', namespace='column')),
path(
'connection/',
include('ontask.connection.urls', namespace='connection')),
path('dataops/', include('ontask.dataops.urls', namespace='dataops')),
path('action/', include('ontask.action.urls', namespace='action')),
path(
'condition/',
include('ontask.condition.urls', namespace='condition')),
path('table/', include('ontask.table.urls', namespace='table')),
path(
'scheduler/',
include('ontask.scheduler.urls', namespace='scheduler')),
path('logs/', include('ontask.logs.urls', namespace='logs')),
path('tinymce/', include('tinymce.urls')),
path(
'ontask_oauth/',
include('ontask.oauth.urls', namespace='ontask_oauth')),
path('tobedone', views.ToBeDone.as_view(), name='tobedone'),
# API AUTH
path(
'api-auth/',
include('rest_framework.urls', namespace='rest_framework')),
# API Doc
re_path(
r'apidoc(?P<format>\.json|\.yaml)$',
schema_view.without_ui(cache_timeout=0),
name='schema-json'),
path(
r'apidoc/',
schema_view.with_ui('swagger', cache_timeout=0),
name='ontask-api-doc'),
# See the 404 page
path('404/', views.Custom404View.as_view(), name="custom_404"),
]
# User-uploaded files like profile pics need to be served in development
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += i18n_patterns(
path(
'jsi18n',
cache_page(
86400,
key_prefix='js18n-%s' % ontask_version())(
JavaScriptCatalog.as_view()),
name='javascript-catalog',
),
)
# Include django debug toolbar if DEBUG is ons
if settings.DEBUG_TOOLBAR and not settings.ONTASK_TESTING:
import debug_toolbar
urlpatterns += [path(r'__debug__/', include(debug_toolbar.urls))]
if settings.PROFILE_SILK and not settings.ONTASK_TESTING:
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]
handler400 = 'ontask.core.services.ontask_handler400'
handler403 = 'ontask.core.services.ontask_handler403'
handler404 = 'ontask.core.services.ontask_handler404'
handler500 = 'ontask.core.services.ontask_handler500'
# Create the DB engine with SQLAlchemy (once!)
pandas.set_engine()
# Make sure the Site has the right information
try:
Site.objects.filter(id=settings.SITE_ID).update(
domain=settings.DOMAIN_NAME,
name=settings.DOMAIN_NAME)
except Exception:
# To bypass the migrate command execution that fails because the Site
# table is not created yet.
site = None
# Remove from AVAILABLE_ACTION_TYPES those in DISABLED_ACTIONS
try:
eval_obj = [eval(daction) for daction in settings.DISABLED_ACTIONS]
for atype in eval_obj:
to_remove = next(
afull_type for afull_type in models.Action.ACTION_TYPES.keys()
if atype == afull_type)
models.Action.AVAILABLE_ACTION_TYPES.pop(to_remove)
except Exception:
raise Exception(
'Unable to configure available action types. '
+ 'Review variable DISABLED_ACTIONS')