-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathinclude_urls.py
More file actions
505 lines (492 loc) · 16.8 KB
/
include_urls.py
File metadata and controls
505 lines (492 loc) · 16.8 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
__copyright__ = "Copyright 2017 Birkbeck, University of London"
__author__ = "Martin Paul Eve & Andy Byers"
__license__ = "AGPL v3"
__maintainer__ = "Birkbeck Centre for Technology and Publishing"
import os
from django.urls import include, path, re_path
from django.conf import settings
from django.views.i18n import JavaScriptCatalog
from django.views.decorators.cache import cache_page
from journal import urls as journal_urls
from core import views as core_views, plugin_loader
from utils import notify
from press import views as press_views
from cms import views as cms_views
from submission import views as submission_views
from journal import views as journal_views
from repository import views as repository_views
from utils.logger import get_logger
logger = get_logger(__name__)
urlpatterns = [
path("", include(journal_urls)),
path("api/", include("api.urls")),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
path("cms/", include("cms.urls")),
path("copyediting/", include("copyediting.urls")),
path("cron/", include("cron.urls")),
path("discussion/", include("discussion.urls")),
path("feed/", include("rss.urls")),
path("i18n/", include("django.conf.urls.i18n")),
path("identifiers/", include("identifiers.urls")),
path("install/", include("install.urls")),
path("metrics/", include("metrics.urls")),
path("news/", include("comms.urls")),
path("oidc/", include("mozilla_django_oidc.urls")),
path("production/", include("production.urls")),
path("proofing/", include("proofing.urls")),
path("reports/", include("reports.urls")),
path("repository/", include("repository.urls")),
path("review/", include("review.urls")),
path("rss/", include("rss.urls")),
path("submit/", include("submission.urls")),
path("transform/", include("transform.urls")),
# As part of the typesetting plugin's merge to core we need to support
# its original url path. Note that the plugin loader will no longer load
# the typesetting plugin.
path("plugins/typesetting/", include("typesetting.urls")),
path("typesetting/", include("typesetting.urls")),
path("utils/", include("utils.urls")),
path("workflow/", include("workflow.urls")),
# Root Site URLS
re_path(r"^$", press_views.index, name="website_index"),
re_path(r"^journals/$", press_views.journals, name="press_journals"),
re_path(r"^conferences/$", press_views.conferences, name="press_conferences"),
re_path(r"^kanban/$", core_views.kanban, name="kanban"),
re_path(r"^login/$", core_views.user_login, name="core_login"),
re_path(r"^login/orcid/$", core_views.user_login_orcid, name="core_login_orcid"),
re_path(r"^register/step/1/$", core_views.register, name="core_register"),
re_path(
r"^register/step/1/(?P<orcid_token>[\w-]+)/$",
core_views.register,
name="core_register_with_orcid_token",
),
re_path(
r"^register/step/2/(?P<token>[\w-]+)/$",
core_views.activate_account,
name="core_confirm_account",
),
re_path(
r"^register/step/orcid/(?P<token>[\w-]+)/$",
core_views.orcid_registration,
name="core_orcid_registration",
),
re_path(
r"^reset/step/1/$", core_views.get_reset_token, name="core_get_reset_token"
),
re_path(
r"^reset/step/2/(?P<token>[\w-]+)/$",
core_views.reset_password,
name="core_reset_password",
),
re_path(r"^profile/$", core_views.edit_profile, name="core_edit_profile"),
re_path(r"^logout/$", core_views.user_logout, name="core_logout"),
re_path(r"^dashboard/$", core_views.dashboard, name="core_dashboard"),
re_path(
r"^dashboard/active/$",
core_views.active_submissions,
name="core_active_submissions",
),
re_path(
r"^dashboard/active/filters/$",
core_views.active_submission_filter,
name="core_submission_filter",
),
re_path(
r"^dashboard/article/(?P<article_id>\d+)/$",
core_views.dashboard_article,
name="core_dashboard_article",
),
re_path(
r"^press/cover/$", press_views.serve_press_cover, name="press_cover_download"
),
re_path(
r"^press/file/(?P<file_id>\d+)/$",
press_views.serve_press_file,
name="serve_press_file",
),
re_path(
r"^press/user/all/$",
press_views.AllUsers.as_view(),
name="press_all_users",
),
re_path(r"^press/merge_users/$", press_views.merge_users, name="merge_users"),
re_path(
r"^doi_manager/$",
press_views.IdentifierManager.as_view(),
name="press_identifier_manager",
),
# Notes
re_path(
r"^article/(?P<article_id>\d+)/note/(?P<note_id>\d+)/delete/$",
core_views.delete_note,
name="kanban_delete_note",
),
# Manager URLS
re_path(r"^manager/$", core_views.manager_index, name="core_manager_index"),
# Settings Management
re_path(
r"^manager/settings/$", core_views.settings_index, name="core_settings_index"
),
re_path(
r"^manager/default_settings/$",
core_views.default_settings_index,
name="core_default_settings_index",
),
re_path(
r"^manager/settings/group/(?P<setting_group>[-\w.: ]+)/setting/(?P<setting_name>[-\w.]+)/$",
core_views.edit_setting,
name="core_edit_setting",
),
re_path(
r"^manager/settings/group/(?P<setting_group>[-\w.: ]+)/default_setting/(?P<setting_name>[-\w.]+)/$",
core_views.edit_setting,
name="core_edit_default_setting",
),
re_path(
r"^manager/settings/(?P<display_group>[-\w.]+)/$",
core_views.edit_settings_group,
name="core_edit_settings_group",
),
re_path(
r"^manager/settings/(?P<plugin>[-\w.:]+)/(?P<setting_group_name>[-\w.]+)/(?P<journal>\d+)/$",
core_views.edit_plugin_settings_groups,
name="core_edit_plugin_settings_groups",
),
re_path(
r"^manager/home/settings/$",
core_views.settings_home,
name="home_settings_index",
),
re_path(
r"^manager/home/settings/order/$",
core_views.journal_home_order,
name="journal_home_order",
),
# Role Management
re_path(r"^manager/roles/$", core_views.roles, name="core_manager_roles"),
re_path(
r"^manager/roles/(?P<slug>[-\w.]+)/$", core_views.role, name="core_manager_role"
),
re_path(
r"^manager/roles/(?P<slug>[-\w.]+)/user/(?P<user_id>\d+)/(?P<action>[-\w.]+)/$",
core_views.role_action,
name="core_manager_role_action",
),
# Users
re_path(r"^manager/user/$", core_views.users, name="core_manager_users"),
re_path(
r"^manager/user/enrol/$",
core_views.enrol_users,
name="core_manager_enrol_users",
),
re_path(
r"^manager/user/inactive/$",
core_views.inactive_users,
name="core_manager_inactive_users",
),
re_path(
r"^manager/user/authenticated/$",
core_views.logged_in_users,
name="core_logged_in_users",
),
re_path(r"^manager/user/add/$", core_views.add_user, name="core_add_user"),
re_path(
r"^manager/user/(?P<user_id>\d+)/edit/$",
core_views.user_edit,
name="core_user_edit",
),
re_path(
r"^manager/user/(?P<user_id>\d+)/history/$",
core_views.user_history,
name="core_user_history",
),
# Affiliations
re_path(
r"^profile/organization/search/$",
core_views.OrganizationListView.as_view(),
name="core_organization_search",
),
re_path(
r"^profile/organization_name/create/$",
core_views.organization_name_create,
name="core_organization_name_create",
),
re_path(
r"^profile/organization_name/(?P<organization_name_id>\d+)/update/$",
core_views.organization_name_update,
name="core_organization_name_update",
),
re_path(
r"^profile/organization/(?P<organization_id>\d+)/affiliation/create/$",
core_views.affiliation_create,
name="core_affiliation_create",
),
re_path(
r"^profile/affiliation/(?P<affiliation_id>\d+)/update/$",
core_views.affiliation_update,
name="core_affiliation_update",
),
re_path(
r"^profile/affiliation/update-from-orcid/(?P<how_many>primary|all)/$",
core_views.affiliation_update_from_orcid,
name="core_affiliation_update_from_orcid",
),
re_path(
r"^profile/affiliation/(?P<affiliation_id>\d+)/delete/$",
core_views.affiliation_delete,
name="core_affiliation_delete",
),
# Templates
re_path(
r"^manager/templates/$", core_views.email_templates, name="core_email_templates"
),
# Articles Images
re_path(
r"^manager/article/images/$",
core_views.article_images,
name="core_article_images",
),
re_path(
r"^manager/article/images/edit/(?P<article_pk>\d+)/$",
core_views.article_image_edit,
name="core_article_image_edit",
),
# Journal Contacts
re_path(r"^manager/contacts/$", core_views.contacts, name="core_journal_contacts"),
re_path(
r"^manager/contacts/add/$",
core_views.edit_contacts,
name="core_new_journal_contact",
),
re_path(
r"^manager/contacts/(?P<contact_id>\d+)/$",
core_views.edit_contacts,
name="core_journal_contact",
),
re_path(
r"^manager/contacts/order/$",
core_views.contacts_order,
name="core_journal_contacts_order",
),
# Editorial Team
re_path(
r"^manager/editorial/$", core_views.editorial_team, name="core_editorial_team"
),
re_path(
r"^manager/editorial/(?P<group_id>\d+)/$",
core_views.edit_editorial_group,
name="core_edit_editorial_team",
),
re_path(
r"^manager/editorial/new/$",
core_views.edit_editorial_group,
name="core_add_editorial_team",
),
re_path(
r"^manager/editorial/(?P<group_id>\d+)/add/$",
core_views.add_member_to_group,
name="core_editorial_member_to_group",
),
re_path(
r"^manager/editorial/(?P<group_id>\d+)/add/(?P<user_id>\d+)/$",
core_views.add_member_to_group,
name="core_editorial_member_to_group_user",
),
re_path(
r"^manager/editorial/order/(?P<type_to_order>[-\w.]+)/$",
core_views.editorial_ordering,
name="core_editorial_ordering",
),
re_path(
r"^manager/editorial/order/(?P<type_to_order>[-\w.]+)/group/(?P<group_id>\d+)/$",
core_views.editorial_ordering,
name="core_editorial_ordering_group",
),
# Notifications
re_path(
r"^manager/notifications/$",
core_views.manage_notifications,
name="core_manager_notifications",
),
re_path(
r"^manager/notifications/(?P<notification_id>\d+)/$",
core_views.manage_notifications,
name="core_manager_edit_notifications",
),
# Plugin home
re_path(r"^manager/plugins/$", core_views.plugin_list, name="core_plugin_list"),
re_path(r"^plugins/$", core_views.plugin_list, name="core_plugin_list"),
# Journal Sections
re_path(
r"^manager/sections/$", core_views.section_list, name="core_manager_sections"
),
re_path(
r"^manager/sections/add/$",
core_views.manage_section,
name="core_manager_section_add",
),
re_path(
r"^manager/sections/(?P<section_id>\d+)/$",
core_views.manage_section,
name="core_manager_section",
),
re_path(
r"^manager/sections/(?P<section_id>\d+)/articles/$",
core_views.section_articles,
name="core_manager_section_articles",
),
# Pinned Articles
re_path(
r"^manager/articles/pinned/$",
core_views.pinned_articles,
name="core_pinned_articles",
),
# Press manager
re_path(r"^manager/press/$", press_views.edit_press, name="press_edit_press"),
re_path(
r"^manager/press/journal_order/$",
press_views.journal_order,
name="press_journal_order",
),
re_path(
r"^manager/press/journal/(?P<journal_id>\d+)/domain/$",
press_views.journal_domain,
name="press_journal_domain",
),
re_path(
r"^manager/press/journal/(?P<journal_id>\d+)/description/$",
press_views.edit_press_journal_description,
name="edit_press_journal_description",
),
# Workflow
re_path(r"^workflow/$", core_views.journal_workflow, name="core_journal_workflow"),
re_path(
r"^workflow/order/$",
core_views.order_workflow_elements,
name="core_order_workflow_elements",
),
# Cache
re_path(r"^manager/cache/flush/$", core_views.flush_cache, name="core_flush_cache"),
re_path(
r"^edit/article/(?P<article_id>\d+)/metadata/$",
submission_views.edit_metadata,
name="edit_metadata",
),
re_path(
r"^edit/article/(?P<article_id>\d+)/author-metadata/$",
submission_views.edit_author_metadata,
name="submission_edit_author_metadata",
),
re_path(
r"^edit/article/(?P<article_id>\d+)/current-authors/$",
submission_views.edit_current_authors,
name="submission_edit_current_authors",
),
re_path(
r"^edit/article/(?P<article_id>\d+)/authors/order/$",
submission_views.order_authors,
name="order_authors",
),
# Public Profiles
re_path(
r"profile/(?P<uuid>[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})/$",
core_views.public_profile,
name="core_public_profile",
),
re_path(r"^robots.txt$", press_views.robots, name="website_robots"),
re_path(r"^sitemap.xml$", press_views.sitemap, name="website_sitemap"),
re_path(
r"^issue/(?P<issue_id>\d+)_sitemap.xml$",
journal_views.sitemap,
name="journal_sitemap",
),
re_path(
r"^subject/(?P<subject_id>\d+)_sitemap.xml$",
repository_views.sitemap,
name="repository_sitemap",
),
re_path(
r"^download/file/(?P<file_id>\d+)/$",
journal_views.download_journal_file,
name="journal_file",
),
re_path(r"^set-timezone/$", core_views.set_session_timezone, name="set_timezone"),
re_path(
r"^jsi18n/$",
cache_page(60 * 60, key_prefix="jsi18n_catalog")(JavaScriptCatalog.as_view()),
name="javascript-catalog",
),
re_path(
r"permission/submit/$",
core_views.request_submission_access,
name="request_submission_access",
),
re_path(
r"permission/requests/$",
core_views.manage_access_requests,
name="manage_access_requests",
),
re_path(
r"^manager/account/(?P<account_id>\d+)/request_orcid/$",
core_views.request_orcid,
name="request_orcid",
),
]
# Journal homepage block loading
blocks = plugin_loader.load(
os.path.join("core", "homepage_elements"),
prefix="core.homepage_elements",
permissive=True,
)
if blocks:
for block in blocks:
try:
urlpatterns += [
re_path(
r"^homepage/elements/{0}/".format(block.name),
include("core.homepage_elements.{0}.urls".format(block.name)),
),
]
logger.debug("Loaded URLs for %s", block.name)
except ImportError as error:
logger.warning(
"Failed to import urls for homepage element %s: %s",
block.name,
error,
)
except Exception as error:
logger.error("Error loading homepage element %s", block.name)
logger.exception(error)
# Plugin Loading
# TODO: plugin_loader should handle the logic below
plugins = plugin_loader.load()
if plugins:
for plugin in plugins:
try:
urlpatterns += [
re_path(
r"^plugins/{0}/".format(plugin.best_name(slug=True)),
include("plugins.{0}.urls".format(plugin.name)),
),
]
logger.debug("Loaded URLs for %s", plugin.name)
except ImportError as error:
logger.warning(
"Failed to import urls for plugin %s: %s",
plugin.name,
error,
)
except Exception as error:
print("Error loading plugin %s", plugin.name)
logger.error("Error loading plugin %s", plugin.name)
logger.exception(error)
# load the notification plugins
if len(settings.NOTIFY_FUNCS) == 0:
plugins = notify.load_modules()
frameworks = []
for key, val in plugins.items():
if hasattr(val, "notify_hook"):
settings.NOTIFY_FUNCS.append(val.notify_hook)
urlpatterns += [
re_path(r"^site/(?P<page_name>.*)/$", cms_views.view_page, name="cms_page"),
]