forked from openwisp/openwisp-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
urls.py
48 lines (45 loc) · 1.45 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
from django.conf import settings
from django.conf.urls import include, url
url_metadata = [
# allauth proxy
{
'regexp': r'^accounts/',
'app': 'openwisp_users',
'include': {'module': 'openwisp_users.accounts.urls'},
},
# openwisp_controller.pki (CRL view)
{
'regexp': r'^',
'app': 'openwisp_controller.pki',
'include': {'module': '{app}.urls', 'namespace': 'x509'},
},
# openwisp_controller controller
{
'regexp': r'^',
'app': 'openwisp_controller.config',
'include': {'module': '{app}.controller.urls', 'namespace': 'controller'},
},
# owm_legacy
{
'regexp': r'^',
'app': 'owm_legacy',
'include': {'module': '{app}.urls', 'namespace': 'owm'},
},
# openwisp_controller.geo
{
'regexp': r'^',
'app': 'openwisp_controller.geo',
'include': {'module': '{app}.api.urls', 'namespace': 'geo'},
},
]
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(url(meta['regexp'], include(module, **meta['include'])))