From 1bbe7df79782c46bb463cad27f324d6df057968a Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 31 Aug 2020 00:49:41 +0200 Subject: [PATCH] API app must have no dependency --- apps/api/urls.py | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/apps/api/urls.py b/apps/api/urls.py index e3eb2a83..9b4d44de 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -1,6 +1,7 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from django.conf import settings from django.conf.urls import url, include from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType @@ -8,15 +9,8 @@ from django.db.models import Q from django_filters.rest_framework import DjangoFilterBackend from rest_framework import routers, serializers from rest_framework.viewsets import ReadOnlyModelViewSet -from activity.api.urls import register_activity_urls from api.viewsets import ReadProtectedModelViewSet -from member.api.urls import register_members_urls -from note.api.urls import register_note_urls from note.models import Alias -from treasury.api.urls import register_treasury_urls -from logs.api.urls import register_logs_urls -from permission.api.urls import register_permission_urls -from wei.api.urls import register_wei_urls class UserSerializer(serializers.ModelSerializer): @@ -112,13 +106,34 @@ class ContentTypeViewSet(ReadOnlyModelViewSet): router = routers.DefaultRouter() router.register('models', ContentTypeViewSet) router.register('user', UserViewSet) -register_members_urls(router, 'members') -register_activity_urls(router, 'activity') -register_note_urls(router, 'note') -register_treasury_urls(router, 'treasury') -register_permission_urls(router, 'permission') -register_logs_urls(router, 'logs') -register_wei_urls(router, 'wei') + +if "member" in settings.INSTALLED_APPS: + from member.api.urls import register_members_urls + register_members_urls(router, 'members') + +if "member" in settings.INSTALLED_APPS: + from activity.api.urls import register_activity_urls + register_activity_urls(router, 'activity') + +if "note" in settings.INSTALLED_APPS: + from note.api.urls import register_note_urls + register_note_urls(router, 'note') + +if "treasury" in settings.INSTALLED_APPS: + from treasury.api.urls import register_treasury_urls + register_treasury_urls(router, 'treasury') + +if "permission" in settings.INSTALLED_APPS: + from permission.api.urls import register_permission_urls + register_permission_urls(router, 'permission') + +if "logs" in settings.INSTALLED_APPS: + from logs.api.urls import register_logs_urls + register_logs_urls(router, 'logs') + +if "wei" in settings.INSTALLED_APPS: + from wei.api.urls import register_wei_urls + register_wei_urls(router, 'wei') app_name = 'api'