gestioCOF/cof/urls.py

72 lines
2.3 KiB
Python
Raw Normal View History

2016-11-06 15:39:14 +01:00
"""
Fichier principal de configuration des urls du projet GestioCOF
"""
2016-07-09 19:49:38 +02:00
from django.conf import settings
2018-02-03 22:34:37 +01:00
from django.conf.urls.i18n import i18n_patterns
2016-07-09 19:49:38 +02:00
from django.conf.urls.static import static
from django.contrib import admin
2019-04-12 17:05:18 +02:00
from django.urls import include, path
from django.views.generic.base import RedirectView
admin.autodiscover()
urlpatterns = [
# Redirection / → /gestion, only useful for developpers.
path("", RedirectView.as_view(url="gestion/")),
# Website administration (independent from installed apps)
2019-04-12 17:05:18 +02:00
path("admin/doc/", include("django.contrib.admindocs.urls")),
path("admin/", admin.site.urls),
]
2020-08-11 17:20:52 +02:00
# App-specific urls
2020-09-01 15:17:10 +02:00
bds_is_alone = (
"bds" in settings.INSTALLED_APPS and "gestioncof" not in settings.INSTALLED_APPS
)
2020-08-11 17:20:52 +02:00
app_dict = {
2020-09-01 15:17:10 +02:00
"bds": "" if bds_is_alone else "bds/",
2020-08-11 17:38:57 +02:00
"kfet": "k-fet/",
# Below = GestioCOF → goes under gestion/
"gestioncof": "gestion/",
"bda": "gestion/bda/",
"petitscours": "gestion/petitcours/",
"events": "gestion/event_v2/", # the events module is still experimental !
"authens": "gestion/authens/",
2020-08-11 17:20:52 +02:00
}
for (app_name, url_prefix) in app_dict.items():
if app_name in settings.INSTALLED_APPS:
urlpatterns += [path(url_prefix, include("{}.urls".format(app_name)))]
if "django_js_reverse" in settings.INSTALLED_APPS:
from django_js_reverse.views import urls_js
urlpatterns += [
path("jsreverse/", urls_js, name="js_reverse"),
]
if "debug_toolbar" in settings.INSTALLED_APPS:
2016-11-06 15:39:14 +01:00
import debug_toolbar
2019-04-12 17:05:18 +02:00
urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]
2016-11-06 15:39:14 +01:00
if settings.DEBUG:
# Si on est en production, MEDIA_ROOT est servi par Apache.
# Il faut dire à Django de servir MEDIA_ROOT lui-même en développement.
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
2020-08-11 17:20:52 +02:00
# Wagtail URLs (wagtail.core urls must be last, as catch-all)
if "wagtail.core" in settings.INSTALLED_APPS:
2020-08-11 17:20:52 +02:00
from wagtail.admin import urls as wagtailadmin_urls
2020-08-11 17:42:56 +02:00
from wagtail.core import urls as wagtail_urls
2020-08-11 17:20:52 +02:00
from wagtail.documents import urls as wagtaildocs_urls
2020-08-11 17:20:52 +02:00
urlpatterns += [
path("cms/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
]
urlpatterns += i18n_patterns(
path("", include(wagtail_urls)), prefix_default_language=False
)