From 55722b801a196c5bc83eb19efa527f77e94f0e8a Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 18 Feb 2020 11:58:42 +0100 Subject: [PATCH] Split API in each app --- apps/{api/activity => activity/api}/__init__.py | 0 apps/{api/activity => activity/api}/serializers.py | 2 +- apps/{api/activity => activity/api}/urls.py | 0 apps/{api/activity => activity/api}/views.py | 2 +- apps/api/urls.py | 13 ++++--------- apps/{api/members => member/api}/__init__.py | 0 apps/{api/members => member/api}/serializers.py | 2 +- apps/{api/members => member/api}/urls.py | 0 apps/{api/members => member/api}/views.py | 2 +- apps/{api/note => note/api}/__init__.py | 0 apps/{api/note => note/api}/serializers.py | 4 ++-- apps/{api/note => note/api}/urls.py | 0 apps/{api/note => note/api}/views.py | 4 ++-- 13 files changed, 12 insertions(+), 17 deletions(-) rename apps/{api/activity => activity/api}/__init__.py (100%) rename apps/{api/activity => activity/api}/serializers.py (94%) rename apps/{api/activity => activity/api}/urls.py (100%) rename apps/{api/activity => activity/api}/views.py (95%) rename apps/{api/members => member/api}/__init__.py (100%) rename apps/{api/members => member/api}/serializers.py (95%) rename apps/{api/members => member/api}/urls.py (100%) rename apps/{api/members => member/api}/views.py (96%) rename apps/{api/note => note/api}/__init__.py (100%) rename apps/{api/note => note/api}/serializers.py (94%) rename apps/{api/note => note/api}/urls.py (100%) rename apps/{api/note => note/api}/views.py (97%) diff --git a/apps/api/activity/__init__.py b/apps/activity/api/__init__.py similarity index 100% rename from apps/api/activity/__init__.py rename to apps/activity/api/__init__.py diff --git a/apps/api/activity/serializers.py b/apps/activity/api/serializers.py similarity index 94% rename from apps/api/activity/serializers.py rename to apps/activity/api/serializers.py index 8ab5d901..f7f949e7 100644 --- a/apps/api/activity/serializers.py +++ b/apps/activity/api/serializers.py @@ -2,7 +2,7 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from activity.models import ActivityType, Activity, Guest +from ..models import ActivityType, Activity, Guest from rest_framework import serializers class ActivityTypeSerializer(serializers.ModelSerializer): diff --git a/apps/api/activity/urls.py b/apps/activity/api/urls.py similarity index 100% rename from apps/api/activity/urls.py rename to apps/activity/api/urls.py diff --git a/apps/api/activity/views.py b/apps/activity/api/views.py similarity index 95% rename from apps/api/activity/views.py rename to apps/activity/api/views.py index de6b8979..4a0973e5 100644 --- a/apps/api/activity/views.py +++ b/apps/activity/api/views.py @@ -4,7 +4,7 @@ from rest_framework import viewsets -from activity.models import ActivityType, Activity, Guest +from ..models import ActivityType, Activity, Guest from .serializers import ActivityTypeSerializer, ActivitySerializer, GuestSerializer diff --git a/apps/api/urls.py b/apps/api/urls.py index 6fe3e99f..7ac56ca1 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -7,9 +7,9 @@ from django.contrib.auth.models import User from rest_framework import routers, serializers, viewsets from rest_framework.authtoken import views as token_views -from .activity.urls import register_activity_urls -from .members.urls import register_members_urls -from .note.urls import register_note_urls +from activity.api.urls import register_activity_urls +from member.api.urls import register_members_urls +from note.api.urls import register_note_urls class UserSerializer(serializers.ModelSerializer): @@ -34,16 +34,11 @@ class UserViewSet(viewsets.ModelViewSet): # Routers provide an easy way of automatically determining the URL conf. +# Register each app API router and user viewset router = routers.DefaultRouter() router.register('user', UserViewSet) - -# Routers for members app register_members_urls(router, 'members') - -# Routers for activity app register_activity_urls(router, 'activity') - -# Routers for note app register_note_urls(router, 'note') app_name = 'api' diff --git a/apps/api/members/__init__.py b/apps/member/api/__init__.py similarity index 100% rename from apps/api/members/__init__.py rename to apps/member/api/__init__.py diff --git a/apps/api/members/serializers.py b/apps/member/api/serializers.py similarity index 95% rename from apps/api/members/serializers.py rename to apps/member/api/serializers.py index 76829615..cf4420d5 100644 --- a/apps/api/members/serializers.py +++ b/apps/member/api/serializers.py @@ -2,7 +2,7 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from member.models import Profile, Club, Role, Membership +from ..models import Profile, Club, Role, Membership from rest_framework import serializers diff --git a/apps/api/members/urls.py b/apps/member/api/urls.py similarity index 100% rename from apps/api/members/urls.py rename to apps/member/api/urls.py diff --git a/apps/api/members/views.py b/apps/member/api/views.py similarity index 96% rename from apps/api/members/views.py rename to apps/member/api/views.py index 06b95dcc..36e8a33f 100644 --- a/apps/api/members/views.py +++ b/apps/member/api/views.py @@ -4,7 +4,7 @@ from rest_framework import viewsets -from member.models import Profile, Club, Role, Membership +from ..models import Profile, Club, Role, Membership from .serializers import ProfileSerializer, ClubSerializer, RoleSerializer, MembershipSerializer diff --git a/apps/api/note/__init__.py b/apps/note/api/__init__.py similarity index 100% rename from apps/api/note/__init__.py rename to apps/note/api/__init__.py diff --git a/apps/api/note/serializers.py b/apps/note/api/serializers.py similarity index 94% rename from apps/api/note/serializers.py rename to apps/note/api/serializers.py index 34a1f368..afc3b419 100644 --- a/apps/api/note/serializers.py +++ b/apps/note/api/serializers.py @@ -2,8 +2,8 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias -from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction +from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias +from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction from rest_framework import serializers from rest_polymorphic.serializers import PolymorphicSerializer diff --git a/apps/api/note/urls.py b/apps/note/api/urls.py similarity index 100% rename from apps/api/note/urls.py rename to apps/note/api/urls.py diff --git a/apps/api/note/views.py b/apps/note/api/views.py similarity index 97% rename from apps/api/note/views.py rename to apps/note/api/views.py index 07bc9fd2..37ca4e20 100644 --- a/apps/api/note/views.py +++ b/apps/note/api/views.py @@ -5,8 +5,8 @@ from django.db.models import Q from rest_framework import viewsets -from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias -from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction +from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias +from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction from .serializers import NoteSerializer, NotePolymorphicSerializer, NoteClubSerializer, NoteSpecialSerializer, \ NoteUserSerializer, AliasSerializer, \ TransactionTemplateSerializer, TransactionSerializer, MembershipTransactionSerializer