From dbdff06e686ccba1649f77539e4cf0a48bf9b8f5 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 29 Dec 2020 15:42:41 +0200 Subject: [PATCH] Move all the routers under their own dir. --- etebase_fastapi/main.py | 10 +++++----- etebase_fastapi/routers/__init__.py | 0 etebase_fastapi/{ => routers}/authentication.py | 8 ++++---- etebase_fastapi/{ => routers}/collection.py | 12 ++++++------ etebase_fastapi/{ => routers}/invitation.py | 6 +++--- etebase_fastapi/{ => routers}/member.py | 6 +++--- etebase_fastapi/{ => routers}/test_reset_view.py | 6 +++--- 7 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 etebase_fastapi/routers/__init__.py rename etebase_fastapi/{ => routers}/authentication.py (97%) rename etebase_fastapi/{ => routers}/collection.py (98%) rename etebase_fastapi/{ => routers}/invitation.py (98%) rename etebase_fastapi/{ => routers}/member.py (94%) rename etebase_fastapi/{ => routers}/test_reset_view.py (90%) diff --git a/etebase_fastapi/main.py b/etebase_fastapi/main.py index 534798e..8e8469c 100644 --- a/etebase_fastapi/main.py +++ b/etebase_fastapi/main.py @@ -6,11 +6,11 @@ from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.trustedhost import TrustedHostMiddleware from .exceptions import CustomHttpException -from .authentication import authentication_router -from .collection import collection_router, item_router -from .member import member_router -from .invitation import invitation_incoming_router, invitation_outgoing_router from .msgpack import MsgpackResponse +from .routers.authentication import authentication_router +from .routers.collection import collection_router, item_router +from .routers.member import member_router +from .routers.invitation import invitation_incoming_router, invitation_outgoing_router def create_application(prefix="", middlewares=[]): @@ -38,7 +38,7 @@ def create_application(prefix="", middlewares=[]): ) if settings.DEBUG: - from etebase_fastapi.test_reset_view import test_reset_view_router + from etebase_fastapi.routers.test_reset_view import test_reset_view_router app.include_router(test_reset_view_router, prefix=f"{BASE_PATH}/test/authentication") diff --git a/etebase_fastapi/routers/__init__.py b/etebase_fastapi/routers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/etebase_fastapi/authentication.py b/etebase_fastapi/routers/authentication.py similarity index 97% rename from etebase_fastapi/authentication.py rename to etebase_fastapi/routers/authentication.py index e77cdb8..4b1b57a 100644 --- a/etebase_fastapi/authentication.py +++ b/etebase_fastapi/routers/authentication.py @@ -20,10 +20,10 @@ from django_etebase.models import UserInfo from django_etebase.signals import user_signed_up from django_etebase.utils import create_user, get_user_queryset, CallbackContext from myauth.models import UserType, get_typed_user_model -from .exceptions import AuthenticationFailed, transform_validation_error, HttpError -from .msgpack import MsgpackRoute -from .utils import BaseModel, permission_responses, msgpack_encode, msgpack_decode -from .dependencies import AuthData, get_auth_data, get_authenticated_user +from ..exceptions import AuthenticationFailed, transform_validation_error, HttpError +from ..msgpack import MsgpackRoute +from ..utils import BaseModel, permission_responses, msgpack_encode, msgpack_decode +from ..dependencies import AuthData, get_auth_data, get_authenticated_user User = get_typed_user_model() authentication_router = APIRouter(route_class=MsgpackRoute) diff --git a/etebase_fastapi/collection.py b/etebase_fastapi/routers/collection.py similarity index 98% rename from etebase_fastapi/collection.py rename to etebase_fastapi/routers/collection.py index 14abee9..56afd7b 100644 --- a/etebase_fastapi/collection.py +++ b/etebase_fastapi/routers/collection.py @@ -10,10 +10,10 @@ from fastapi import APIRouter, Depends, status, Request from django_etebase import models from myauth.models import UserType, get_typed_user_model from .authentication import get_authenticated_user -from .exceptions import HttpError, transform_validation_error, PermissionDenied, ValidationError -from .msgpack import MsgpackRoute -from .stoken_handler import filter_by_stoken_and_limit, filter_by_stoken, get_stoken_obj, get_queryset_stoken -from .utils import ( +from ..exceptions import HttpError, transform_validation_error, PermissionDenied, ValidationError +from ..msgpack import MsgpackRoute +from ..stoken_handler import filter_by_stoken_and_limit, filter_by_stoken, get_stoken_obj, get_queryset_stoken +from ..utils import ( get_object_or_404, Context, Prefetch, @@ -24,8 +24,8 @@ from .utils import ( PERMISSIONS_READ, PERMISSIONS_READWRITE, ) -from .dependencies import get_collection_queryset, get_item_queryset, get_collection -from .sendfile import sendfile +from ..dependencies import get_collection_queryset, get_item_queryset, get_collection +from ..sendfile import sendfile User = get_typed_user_model collection_router = APIRouter(route_class=MsgpackRoute, responses=permission_responses) diff --git a/etebase_fastapi/invitation.py b/etebase_fastapi/routers/invitation.py similarity index 98% rename from etebase_fastapi/invitation.py rename to etebase_fastapi/routers/invitation.py index eb9f549..6a06c60 100644 --- a/etebase_fastapi/invitation.py +++ b/etebase_fastapi/routers/invitation.py @@ -8,9 +8,9 @@ from django_etebase import models from django_etebase.utils import get_user_queryset, CallbackContext from myauth.models import UserType, get_typed_user_model from .authentication import get_authenticated_user -from .exceptions import HttpError, PermissionDenied -from .msgpack import MsgpackRoute -from .utils import ( +from ..exceptions import HttpError, PermissionDenied +from ..msgpack import MsgpackRoute +from ..utils import ( get_object_or_404, Context, is_collection_admin, diff --git a/etebase_fastapi/member.py b/etebase_fastapi/routers/member.py similarity index 94% rename from etebase_fastapi/member.py rename to etebase_fastapi/routers/member.py index 22977ac..210374c 100644 --- a/etebase_fastapi/member.py +++ b/etebase_fastapi/routers/member.py @@ -7,9 +7,9 @@ from fastapi import APIRouter, Depends, status from django_etebase import models from myauth.models import UserType, get_typed_user_model from .authentication import get_authenticated_user -from .msgpack import MsgpackRoute -from .utils import get_object_or_404, BaseModel, permission_responses, PERMISSIONS_READ, PERMISSIONS_READWRITE -from .stoken_handler import filter_by_stoken_and_limit +from ..msgpack import MsgpackRoute +from ..utils import get_object_or_404, BaseModel, permission_responses, PERMISSIONS_READ, PERMISSIONS_READWRITE +from ..stoken_handler import filter_by_stoken_and_limit from .collection import get_collection, verify_collection_admin diff --git a/etebase_fastapi/test_reset_view.py b/etebase_fastapi/routers/test_reset_view.py similarity index 90% rename from etebase_fastapi/test_reset_view.py rename to etebase_fastapi/routers/test_reset_view.py index e328875..09638e4 100644 --- a/etebase_fastapi/test_reset_view.py +++ b/etebase_fastapi/routers/test_reset_view.py @@ -4,9 +4,9 @@ from django.shortcuts import get_object_or_404 from fastapi import APIRouter, Request, status from django_etebase.utils import get_user_queryset, CallbackContext -from etebase_fastapi.authentication import SignupIn, signup_save -from etebase_fastapi.msgpack import MsgpackRoute -from etebase_fastapi.exceptions import HttpError +from .authentication import SignupIn, signup_save +from ..msgpack import MsgpackRoute +from ..exceptions import HttpError from myauth.models import get_typed_user_model test_reset_view_router = APIRouter(route_class=MsgpackRoute, tags=["test helpers"])