forked from crowdbotics-apps/haileyshealthyhango-48467
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurls.py
29 lines (24 loc) · 902 Bytes
/
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
from pathlib import Path
from django.conf import settings
from django.urls import path, include
from django.db.utils import ProgrammingError
from .utils import posixpath_to_modulepath
urlpatterns = []
# BE CAREFUL! Do not remove or change this code snippet, this is needed to get
# Crowdbotics' official modules working properly.
try:
base_dir = Path(settings.BASE_DIR)
modules_dir = base_dir / "modules"
urls = modules_dir.rglob("urls.py")
for url in urls:
module_name, _ = url.as_posix().split("/")[-2:]
if not module_name == "modules":
module_url = module_name.replace("_", "-")
urlpatterns += [
path(
f"{module_url}/",
include(posixpath_to_modulepath(url.relative_to(base_dir))),
) # noqa
]
except (ImportError, IndexError, ProgrammingError):
pass