-
-
Notifications
You must be signed in to change notification settings - Fork 214
/
Copy pathurls.py
84 lines (81 loc) · 2.5 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
from django.conf import settings
from django.urls import include, path
url_metadata = [
# allauth proxy
{
'regexp': 'accounts/',
'app': 'openwisp_users',
'include': {'module': 'openwisp_users.accounts.urls'},
},
# openwisp_notifications
{
'regexp': '',
'app': 'openwisp_notifications',
'include': {'module': 'openwisp_notifications.urls'},
},
# openwisp_ipam
{
'regexp': '',
'app': 'openwisp_ipam',
'include': {'module': 'openwisp_ipam.urls'},
},
# openwisp_controller.pki (CRL view)
{
'regexp': '',
'app': 'openwisp_controller.pki',
'include': {'module': '{app}.urls', 'namespace': 'x509'},
},
# openwisp_controller.pki.api
{
'regexp': 'api/v1/',
'app': 'openwisp_controller.pki',
'include': {'module': '{app}.api.urls', 'namespace': 'pki_api'},
},
# openwisp_controller controller
{
'regexp': '',
'app': 'openwisp_controller.config',
'include': {'module': '{app}.controller.urls', 'namespace': 'controller'},
},
# owm_legacy
{
'regexp': '',
'app': 'owm_legacy',
'include': {'module': '{app}.urls', 'namespace': 'owm'},
},
# openwisp_controller.geo
{
'regexp': '',
'app': 'openwisp_controller.geo',
'include': {'module': '{app}.api.urls', 'namespace': 'geo_api'},
},
# openwisp_controller.config
{
'regexp': '',
'app': 'openwisp_controller.config',
'include': {'module': '{app}.urls', 'namespace': 'config'},
},
# openwisp_controller.config.api
{
'regexp': 'api/v1/',
'app': 'openwisp_controller.config',
'include': {'module': '{app}.api.urls', 'namespace': 'config_api'},
},
# openwisp_controller.connection
{
'regexp': '',
'app': 'openwisp_controller.connection',
'include': {'module': '{app}.api.urls', 'namespace': 'connection_api'},
},
]
urlpatterns = []
for meta in url_metadata:
module = meta['include'].pop('module')
if 'app' in meta:
# if app attribute is specified, ensure the app is installed, or skip otherwise
# this allows some flexibility during development or when trying custom setups
if meta['app'] not in settings.INSTALLED_APPS:
continue
# DRY python module path
module = module.format(**meta)
urlpatterns.append(path(meta['regexp'], include(module, **meta['include'])))