From 163f7766f11fd6151bc8b515cc6397a071e148bc Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sun, 8 May 2022 14:54:25 +0200 Subject: [PATCH 1/5] fix: move etebase_fastapi module from toplevel to under etebase_server This is in preparation for creating a python package, which should only occupy the "etebase_server" name in the global module namespace. --- etebase_server/asgi.py | 2 +- {etebase_fastapi => etebase_server/fastapi}/__init__.py | 0 {etebase_fastapi => etebase_server/fastapi}/db_hack.py | 0 {etebase_fastapi => etebase_server/fastapi}/dependencies.py | 0 {etebase_fastapi => etebase_server/fastapi}/exceptions.py | 0 {etebase_fastapi => etebase_server/fastapi}/main.py | 2 +- {etebase_fastapi => etebase_server/fastapi}/msgpack.py | 0 {etebase_fastapi => etebase_server/fastapi}/redis.py | 0 {etebase_fastapi => etebase_server/fastapi}/routers/__init__.py | 0 .../fastapi}/routers/authentication.py | 0 .../fastapi}/routers/collection.py | 0 .../fastapi}/routers/invitation.py | 0 {etebase_fastapi => etebase_server/fastapi}/routers/member.py | 0 .../fastapi}/routers/test_reset_view.py | 0 .../fastapi}/routers/websocket.py | 0 {etebase_fastapi => etebase_server/fastapi}/sendfile/LICENSE | 0 {etebase_fastapi => etebase_server/fastapi}/sendfile/README.md | 0 .../fastapi}/sendfile/__init__.py | 0 .../fastapi}/sendfile/backends/__init__.py | 0 .../fastapi}/sendfile/backends/mod_wsgi.py | 0 .../fastapi}/sendfile/backends/nginx.py | 0 .../fastapi}/sendfile/backends/simple.py | 0 .../fastapi}/sendfile/backends/xsendfile.py | 0 {etebase_fastapi => etebase_server/fastapi}/sendfile/utils.py | 0 {etebase_fastapi => etebase_server/fastapi}/stoken_handler.py | 0 {etebase_fastapi => etebase_server/fastapi}/utils.py | 0 26 files changed, 2 insertions(+), 2 deletions(-) rename {etebase_fastapi => etebase_server/fastapi}/__init__.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/db_hack.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/dependencies.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/exceptions.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/main.py (97%) rename {etebase_fastapi => etebase_server/fastapi}/msgpack.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/redis.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/routers/__init__.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/routers/authentication.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/routers/collection.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/routers/invitation.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/routers/member.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/routers/test_reset_view.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/routers/websocket.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/LICENSE (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/README.md (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/__init__.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/backends/__init__.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/backends/mod_wsgi.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/backends/nginx.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/backends/simple.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/backends/xsendfile.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/sendfile/utils.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/stoken_handler.py (100%) rename {etebase_fastapi => etebase_server/fastapi}/utils.py (100%) diff --git a/etebase_server/asgi.py b/etebase_server/asgi.py index 25dbf77..5a7ffa7 100644 --- a/etebase_server/asgi.py +++ b/etebase_server/asgi.py @@ -7,7 +7,7 @@ django_application = get_asgi_application() def create_application(): - from etebase_fastapi.main import create_application + from etebase_server.fastapi.main import create_application app = create_application() diff --git a/etebase_fastapi/__init__.py b/etebase_server/fastapi/__init__.py similarity index 100% rename from etebase_fastapi/__init__.py rename to etebase_server/fastapi/__init__.py diff --git a/etebase_fastapi/db_hack.py b/etebase_server/fastapi/db_hack.py similarity index 100% rename from etebase_fastapi/db_hack.py rename to etebase_server/fastapi/db_hack.py diff --git a/etebase_fastapi/dependencies.py b/etebase_server/fastapi/dependencies.py similarity index 100% rename from etebase_fastapi/dependencies.py rename to etebase_server/fastapi/dependencies.py diff --git a/etebase_fastapi/exceptions.py b/etebase_server/fastapi/exceptions.py similarity index 100% rename from etebase_fastapi/exceptions.py rename to etebase_server/fastapi/exceptions.py diff --git a/etebase_fastapi/main.py b/etebase_server/fastapi/main.py similarity index 97% rename from etebase_fastapi/main.py rename to etebase_server/fastapi/main.py index 3e0c1e9..74798a4 100644 --- a/etebase_fastapi/main.py +++ b/etebase_server/fastapi/main.py @@ -43,7 +43,7 @@ def create_application(prefix="", middlewares=[]): app.include_router(websocket_router, prefix=f"{BASE_PATH}/ws", tags=["websocket"]) if settings.DEBUG: - from etebase_fastapi.routers.test_reset_view import test_reset_view_router + from .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/msgpack.py b/etebase_server/fastapi/msgpack.py similarity index 100% rename from etebase_fastapi/msgpack.py rename to etebase_server/fastapi/msgpack.py diff --git a/etebase_fastapi/redis.py b/etebase_server/fastapi/redis.py similarity index 100% rename from etebase_fastapi/redis.py rename to etebase_server/fastapi/redis.py diff --git a/etebase_fastapi/routers/__init__.py b/etebase_server/fastapi/routers/__init__.py similarity index 100% rename from etebase_fastapi/routers/__init__.py rename to etebase_server/fastapi/routers/__init__.py diff --git a/etebase_fastapi/routers/authentication.py b/etebase_server/fastapi/routers/authentication.py similarity index 100% rename from etebase_fastapi/routers/authentication.py rename to etebase_server/fastapi/routers/authentication.py diff --git a/etebase_fastapi/routers/collection.py b/etebase_server/fastapi/routers/collection.py similarity index 100% rename from etebase_fastapi/routers/collection.py rename to etebase_server/fastapi/routers/collection.py diff --git a/etebase_fastapi/routers/invitation.py b/etebase_server/fastapi/routers/invitation.py similarity index 100% rename from etebase_fastapi/routers/invitation.py rename to etebase_server/fastapi/routers/invitation.py diff --git a/etebase_fastapi/routers/member.py b/etebase_server/fastapi/routers/member.py similarity index 100% rename from etebase_fastapi/routers/member.py rename to etebase_server/fastapi/routers/member.py diff --git a/etebase_fastapi/routers/test_reset_view.py b/etebase_server/fastapi/routers/test_reset_view.py similarity index 100% rename from etebase_fastapi/routers/test_reset_view.py rename to etebase_server/fastapi/routers/test_reset_view.py diff --git a/etebase_fastapi/routers/websocket.py b/etebase_server/fastapi/routers/websocket.py similarity index 100% rename from etebase_fastapi/routers/websocket.py rename to etebase_server/fastapi/routers/websocket.py diff --git a/etebase_fastapi/sendfile/LICENSE b/etebase_server/fastapi/sendfile/LICENSE similarity index 100% rename from etebase_fastapi/sendfile/LICENSE rename to etebase_server/fastapi/sendfile/LICENSE diff --git a/etebase_fastapi/sendfile/README.md b/etebase_server/fastapi/sendfile/README.md similarity index 100% rename from etebase_fastapi/sendfile/README.md rename to etebase_server/fastapi/sendfile/README.md diff --git a/etebase_fastapi/sendfile/__init__.py b/etebase_server/fastapi/sendfile/__init__.py similarity index 100% rename from etebase_fastapi/sendfile/__init__.py rename to etebase_server/fastapi/sendfile/__init__.py diff --git a/etebase_fastapi/sendfile/backends/__init__.py b/etebase_server/fastapi/sendfile/backends/__init__.py similarity index 100% rename from etebase_fastapi/sendfile/backends/__init__.py rename to etebase_server/fastapi/sendfile/backends/__init__.py diff --git a/etebase_fastapi/sendfile/backends/mod_wsgi.py b/etebase_server/fastapi/sendfile/backends/mod_wsgi.py similarity index 100% rename from etebase_fastapi/sendfile/backends/mod_wsgi.py rename to etebase_server/fastapi/sendfile/backends/mod_wsgi.py diff --git a/etebase_fastapi/sendfile/backends/nginx.py b/etebase_server/fastapi/sendfile/backends/nginx.py similarity index 100% rename from etebase_fastapi/sendfile/backends/nginx.py rename to etebase_server/fastapi/sendfile/backends/nginx.py diff --git a/etebase_fastapi/sendfile/backends/simple.py b/etebase_server/fastapi/sendfile/backends/simple.py similarity index 100% rename from etebase_fastapi/sendfile/backends/simple.py rename to etebase_server/fastapi/sendfile/backends/simple.py diff --git a/etebase_fastapi/sendfile/backends/xsendfile.py b/etebase_server/fastapi/sendfile/backends/xsendfile.py similarity index 100% rename from etebase_fastapi/sendfile/backends/xsendfile.py rename to etebase_server/fastapi/sendfile/backends/xsendfile.py diff --git a/etebase_fastapi/sendfile/utils.py b/etebase_server/fastapi/sendfile/utils.py similarity index 100% rename from etebase_fastapi/sendfile/utils.py rename to etebase_server/fastapi/sendfile/utils.py diff --git a/etebase_fastapi/stoken_handler.py b/etebase_server/fastapi/stoken_handler.py similarity index 100% rename from etebase_fastapi/stoken_handler.py rename to etebase_server/fastapi/stoken_handler.py diff --git a/etebase_fastapi/utils.py b/etebase_server/fastapi/utils.py similarity index 100% rename from etebase_fastapi/utils.py rename to etebase_server/fastapi/utils.py From 9d6e0ae60a88d791ab534631cd4dedb9618fb4d5 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sun, 8 May 2022 15:10:48 +0200 Subject: [PATCH 2/5] fix: move myauth module from toplevel to under etebase_server This is in preparation for creating a python package, which should only occupy the "etebase_server" name in the global module namespace. --- django_etebase/token_auth/models.py | 2 +- django_etebase/utils.py | 2 +- etebase_server/fastapi/dependencies.py | 2 +- etebase_server/fastapi/routers/authentication.py | 2 +- etebase_server/fastapi/routers/collection.py | 2 +- etebase_server/fastapi/routers/invitation.py | 2 +- etebase_server/fastapi/routers/member.py | 2 +- etebase_server/fastapi/routers/test_reset_view.py | 2 +- etebase_server/fastapi/routers/websocket.py | 2 +- etebase_server/fastapi/utils.py | 2 +- {myauth => etebase_server/myauth}/__init__.py | 0 {myauth => etebase_server/myauth}/admin.py | 0 {myauth => etebase_server/myauth}/apps.py | 3 ++- {myauth => etebase_server/myauth}/forms.py | 2 +- .../myauth}/migrations/0001_initial.py | 0 .../myauth}/migrations/0002_auto_20200515_0801.py | 4 ++-- .../myauth}/migrations/0003_auto_20201119_0810.py | 6 +++--- {myauth => etebase_server/myauth}/migrations/__init__.py | 0 {myauth => etebase_server/myauth}/models.py | 0 {myauth => etebase_server/myauth}/tests.py | 0 {myauth => etebase_server/myauth}/views.py | 0 etebase_server/settings.py | 2 +- 22 files changed, 19 insertions(+), 18 deletions(-) rename {myauth => etebase_server/myauth}/__init__.py (100%) rename {myauth => etebase_server/myauth}/admin.py (100%) rename {myauth => etebase_server/myauth}/apps.py (54%) rename {myauth => etebase_server/myauth}/forms.py (92%) rename {myauth => etebase_server/myauth}/migrations/0001_initial.py (100%) rename {myauth => etebase_server/myauth}/migrations/0002_auto_20200515_0801.py (85%) rename {myauth => etebase_server/myauth}/migrations/0003_auto_20201119_0810.py (84%) rename {myauth => etebase_server/myauth}/migrations/__init__.py (100%) rename {myauth => etebase_server/myauth}/models.py (100%) rename {myauth => etebase_server/myauth}/tests.py (100%) rename {myauth => etebase_server/myauth}/views.py (100%) diff --git a/django_etebase/token_auth/models.py b/django_etebase/token_auth/models.py index dd5ae87..de2ffc1 100644 --- a/django_etebase/token_auth/models.py +++ b/django_etebase/token_auth/models.py @@ -1,7 +1,7 @@ from django.db import models from django.utils import timezone from django.utils.crypto import get_random_string -from myauth.models import get_typed_user_model +from etebase_server.myauth.models import get_typed_user_model User = get_typed_user_model() diff --git a/django_etebase/utils.py b/django_etebase/utils.py index 3a05fd4..d4aca72 100644 --- a/django_etebase/utils.py +++ b/django_etebase/utils.py @@ -3,7 +3,7 @@ from dataclasses import dataclass from django.db.models import QuerySet from django.core.exceptions import PermissionDenied -from myauth.models import UserType, get_typed_user_model +from etebase_server.myauth.models import UserType, get_typed_user_model from . import app_settings diff --git a/etebase_server/fastapi/dependencies.py b/etebase_server/fastapi/dependencies.py index 520d499..48894d6 100644 --- a/etebase_server/fastapi/dependencies.py +++ b/etebase_server/fastapi/dependencies.py @@ -8,7 +8,7 @@ from django.db.models import QuerySet from django_etebase import models from django_etebase.token_auth.models import AuthToken, get_default_expiry -from myauth.models import UserType, get_typed_user_model +from etebase_server.myauth.models import UserType, get_typed_user_model from .exceptions import AuthenticationFailed from .utils import get_object_or_404 from .db_hack import django_db_cleanup_decorator diff --git a/etebase_server/fastapi/routers/authentication.py b/etebase_server/fastapi/routers/authentication.py index fd21d21..b271357 100644 --- a/etebase_server/fastapi/routers/authentication.py +++ b/etebase_server/fastapi/routers/authentication.py @@ -19,7 +19,7 @@ from django_etebase.token_auth.models import AuthToken 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 etebase_server.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, get_user_username_email_kwargs diff --git a/etebase_server/fastapi/routers/collection.py b/etebase_server/fastapi/routers/collection.py index c8146f2..3c2e511 100644 --- a/etebase_server/fastapi/routers/collection.py +++ b/etebase_server/fastapi/routers/collection.py @@ -8,7 +8,7 @@ from django.db.models import Q, QuerySet from fastapi import APIRouter, Depends, status, Request, BackgroundTasks from django_etebase import models -from myauth.models import UserType +from etebase_server.myauth.models import UserType from .authentication import get_authenticated_user from .websocket import get_ticket, TicketRequest, TicketOut from ..exceptions import HttpError, transform_validation_error, PermissionDenied, ValidationError diff --git a/etebase_server/fastapi/routers/invitation.py b/etebase_server/fastapi/routers/invitation.py index 7e52978..2ab2f64 100644 --- a/etebase_server/fastapi/routers/invitation.py +++ b/etebase_server/fastapi/routers/invitation.py @@ -6,7 +6,7 @@ from fastapi import APIRouter, Depends, status, Request from django_etebase import models from django_etebase.utils import get_user_queryset, CallbackContext -from myauth.models import UserType, get_typed_user_model +from etebase_server.myauth.models import UserType, get_typed_user_model from .authentication import get_authenticated_user from ..exceptions import HttpError, PermissionDenied from ..msgpack import MsgpackRoute diff --git a/etebase_server/fastapi/routers/member.py b/etebase_server/fastapi/routers/member.py index 38beb79..dff95c1 100644 --- a/etebase_server/fastapi/routers/member.py +++ b/etebase_server/fastapi/routers/member.py @@ -5,7 +5,7 @@ from django.db.models import QuerySet from fastapi import APIRouter, Depends, status from django_etebase import models -from myauth.models import UserType, get_typed_user_model +from etebase_server.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 diff --git a/etebase_server/fastapi/routers/test_reset_view.py b/etebase_server/fastapi/routers/test_reset_view.py index 09638e4..a66d1cc 100644 --- a/etebase_server/fastapi/routers/test_reset_view.py +++ b/etebase_server/fastapi/routers/test_reset_view.py @@ -7,7 +7,7 @@ from django_etebase.utils import get_user_queryset, CallbackContext from .authentication import SignupIn, signup_save from ..msgpack import MsgpackRoute from ..exceptions import HttpError -from myauth.models import get_typed_user_model +from etebase_server.myauth.models import get_typed_user_model test_reset_view_router = APIRouter(route_class=MsgpackRoute, tags=["test helpers"]) User = get_typed_user_model() diff --git a/etebase_server/fastapi/routers/websocket.py b/etebase_server/fastapi/routers/websocket.py index 3fc535f..19cd5e1 100644 --- a/etebase_server/fastapi/routers/websocket.py +++ b/etebase_server/fastapi/routers/websocket.py @@ -10,7 +10,7 @@ import nacl.utils from django_etebase import models from django_etebase.utils import CallbackContext, get_user_queryset -from myauth.models import UserType, get_typed_user_model +from etebase_server.myauth.models import UserType, get_typed_user_model from ..dependencies import get_collection_queryset, get_item_queryset from ..exceptions import NotSupported diff --git a/etebase_server/fastapi/utils.py b/etebase_server/fastapi/utils.py index 09c223e..b215477 100644 --- a/etebase_server/fastapi/utils.py +++ b/etebase_server/fastapi/utils.py @@ -12,7 +12,7 @@ from django.core.exceptions import ObjectDoesNotExist from django_etebase import app_settings from django_etebase.models import AccessLevels -from myauth.models import UserType, get_typed_user_model +from etebase_server.myauth.models import UserType, get_typed_user_model from .exceptions import HttpError, HttpErrorOut diff --git a/myauth/__init__.py b/etebase_server/myauth/__init__.py similarity index 100% rename from myauth/__init__.py rename to etebase_server/myauth/__init__.py diff --git a/myauth/admin.py b/etebase_server/myauth/admin.py similarity index 100% rename from myauth/admin.py rename to etebase_server/myauth/admin.py diff --git a/myauth/apps.py b/etebase_server/myauth/apps.py similarity index 54% rename from myauth/apps.py rename to etebase_server/myauth/apps.py index 96cb29b..65e21b1 100644 --- a/myauth/apps.py +++ b/etebase_server/myauth/apps.py @@ -2,4 +2,5 @@ from django.apps import AppConfig class MyauthConfig(AppConfig): - name = "myauth" + name = "etebase_server.myauth" + label = "myauth" diff --git a/myauth/forms.py b/etebase_server/myauth/forms.py similarity index 92% rename from myauth/forms.py rename to etebase_server/myauth/forms.py index fc2be74..7681835 100644 --- a/myauth/forms.py +++ b/etebase_server/myauth/forms.py @@ -1,6 +1,6 @@ from django import forms from django.contrib.auth.forms import UsernameField -from myauth.models import get_typed_user_model +from etebase_server.myauth.models import get_typed_user_model User = get_typed_user_model() diff --git a/myauth/migrations/0001_initial.py b/etebase_server/myauth/migrations/0001_initial.py similarity index 100% rename from myauth/migrations/0001_initial.py rename to etebase_server/myauth/migrations/0001_initial.py diff --git a/myauth/migrations/0002_auto_20200515_0801.py b/etebase_server/myauth/migrations/0002_auto_20200515_0801.py similarity index 85% rename from myauth/migrations/0002_auto_20200515_0801.py rename to etebase_server/myauth/migrations/0002_auto_20200515_0801.py index 068c9ae..15e35d5 100644 --- a/myauth/migrations/0002_auto_20200515_0801.py +++ b/etebase_server/myauth/migrations/0002_auto_20200515_0801.py @@ -1,7 +1,7 @@ # Generated by Django 3.0.3 on 2020-05-15 08:01 from django.db import migrations, models -import myauth.models +import etebase_server.myauth.models as myauth_models class Migration(migrations.Migration): @@ -19,7 +19,7 @@ class Migration(migrations.Migration): help_text="Required. 150 characters or fewer. Letters, digits and ./+/-/_ only.", max_length=150, unique=True, - validators=[myauth.models.UnicodeUsernameValidator()], + validators=[myauth_models.UnicodeUsernameValidator()], verbose_name="username", ), ), diff --git a/myauth/migrations/0003_auto_20201119_0810.py b/etebase_server/myauth/migrations/0003_auto_20201119_0810.py similarity index 84% rename from myauth/migrations/0003_auto_20201119_0810.py rename to etebase_server/myauth/migrations/0003_auto_20201119_0810.py index cfd2ec3..2fbc236 100644 --- a/myauth/migrations/0003_auto_20201119_0810.py +++ b/etebase_server/myauth/migrations/0003_auto_20201119_0810.py @@ -1,7 +1,7 @@ # Generated by Django 3.1.1 on 2020-11-19 08:10 from django.db import migrations, models -import myauth.models +import etebase_server.myauth.models as myauth_models class Migration(migrations.Migration): @@ -14,7 +14,7 @@ class Migration(migrations.Migration): migrations.AlterModelManagers( name="user", managers=[ - ("objects", myauth.models.UserManager()), + ("objects", myauth_models.UserManager()), ], ), migrations.AlterField( @@ -30,7 +30,7 @@ class Migration(migrations.Migration): help_text="Required. 150 characters or fewer. Letters, digits and ./-/_ only.", max_length=150, unique=True, - validators=[myauth.models.UnicodeUsernameValidator()], + validators=[myauth_models.UnicodeUsernameValidator()], verbose_name="username", ), ), diff --git a/myauth/migrations/__init__.py b/etebase_server/myauth/migrations/__init__.py similarity index 100% rename from myauth/migrations/__init__.py rename to etebase_server/myauth/migrations/__init__.py diff --git a/myauth/models.py b/etebase_server/myauth/models.py similarity index 100% rename from myauth/models.py rename to etebase_server/myauth/models.py diff --git a/myauth/tests.py b/etebase_server/myauth/tests.py similarity index 100% rename from myauth/tests.py rename to etebase_server/myauth/tests.py diff --git a/myauth/views.py b/etebase_server/myauth/views.py similarity index 100% rename from myauth/views.py rename to etebase_server/myauth/views.py diff --git a/etebase_server/settings.py b/etebase_server/settings.py index 07a50b0..f1db11e 100644 --- a/etebase_server/settings.py +++ b/etebase_server/settings.py @@ -54,7 +54,7 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", - "myauth.apps.MyauthConfig", + "etebase_server.myauth.apps.MyauthConfig", "django_etebase.apps.DjangoEtebaseConfig", "django_etebase.token_auth.apps.TokenAuthConfig", ] From ada5181a7e1bd6929225d74f7ce9b613c63e43eb Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sun, 8 May 2022 16:32:29 +0200 Subject: [PATCH 3/5] fix: move django_etebase module from toplevel to under etebase_server This is in preparation for creating a python package, which should only occupy the "etebase_server" name in the global module namespace. --- README.md | 2 +- {django_etebase => etebase_server/django}/__init__.py | 0 .../django}/app_settings_inner.py | 0 {django_etebase => etebase_server/django}/apps.py | 3 ++- .../django}/migrations/0001_initial.py | 4 ++-- .../django}/migrations/0002_userinfo.py | 0 .../django}/migrations/0003_collectioninvitation.py | 0 .../migrations/0004_collectioninvitation_version.py | 0 .../django}/migrations/0005_auto_20200526_1021.py | 0 .../django}/migrations/0006_auto_20200526_1040.py | 0 .../django}/migrations/0007_auto_20200526_1336.py | 0 .../django}/migrations/0008_auto_20200526_1535.py | 4 ++-- .../django}/migrations/0009_auto_20200526_1535.py | 0 .../django}/migrations/0010_auto_20200526_1539.py | 0 .../django}/migrations/0011_collectionmember_stoken.py | 0 .../django}/migrations/0012_auto_20200527_0743.py | 0 .../django}/migrations/0013_collectionmemberremoved.py | 0 .../django}/migrations/0014_auto_20200602_1558.py | 0 .../migrations/0015_collectionitemrevision_salt.py | 0 .../django}/migrations/0016_auto_20200623_0820.py | 0 .../django}/migrations/0017_auto_20200623_0958.py | 0 .../django}/migrations/0018_auto_20200624_0748.py | 0 .../django}/migrations/0019_auto_20200626_0748.py | 0 .../0020_remove_collectionitemrevision_salt.py | 0 .../django}/migrations/0021_auto_20200626_0913.py | 4 ++-- .../django}/migrations/0022_auto_20200804_1059.py | 0 .../migrations/0023_collectionitemchunk_collection.py | 0 .../django}/migrations/0024_auto_20200804_1209.py | 0 .../django}/migrations/0025_auto_20200804_1216.py | 0 .../django}/migrations/0026_auto_20200907_0752.py | 0 .../django}/migrations/0027_auto_20200907_0752.py | 0 .../django}/migrations/0028_auto_20200907_0754.py | 2 +- .../django}/migrations/0029_auto_20200907_0801.py | 0 .../django}/migrations/0030_auto_20200922_0832.py | 0 .../django}/migrations/0031_auto_20201013_1336.py | 0 .../django}/migrations/0032_auto_20201013_1409.py | 0 .../django}/migrations/0033_collection_uid.py | 0 .../django}/migrations/0034_auto_20201214_1124.py | 0 .../django}/migrations/0035_auto_20201214_1126.py | 0 .../django}/migrations/0036_auto_20201214_1128.py | 0 .../django}/migrations/0037_auto_20210127_1237.py | 0 .../django}/migrations/__init__.py | 0 {django_etebase => etebase_server/django}/models.py | 0 {django_etebase => etebase_server/django}/signals.py | 0 .../django}/token_auth/__init__.py | 0 .../django}/token_auth/apps.py | 2 +- .../django}/token_auth/migrations/0001_initial.py | 2 +- .../django}/token_auth/migrations/__init__.py | 0 .../django}/token_auth/models.py | 0 {django_etebase => etebase_server/django}/utils.py | 0 etebase_server/fastapi/dependencies.py | 4 ++-- etebase_server/fastapi/main.py | 2 +- etebase_server/fastapi/redis.py | 2 +- etebase_server/fastapi/routers/authentication.py | 10 +++++----- etebase_server/fastapi/routers/collection.py | 2 +- etebase_server/fastapi/routers/invitation.py | 4 ++-- etebase_server/fastapi/routers/member.py | 2 +- etebase_server/fastapi/routers/test_reset_view.py | 2 +- etebase_server/fastapi/routers/websocket.py | 4 ++-- etebase_server/fastapi/stoken_handler.py | 2 +- etebase_server/fastapi/utils.py | 4 ++-- etebase_server/settings.py | 6 +++--- 62 files changed, 34 insertions(+), 33 deletions(-) rename {django_etebase => etebase_server/django}/__init__.py (100%) rename {django_etebase => etebase_server/django}/app_settings_inner.py (100%) rename {django_etebase => etebase_server/django}/apps.py (53%) rename {django_etebase => etebase_server/django}/migrations/0001_initial.py (98%) rename {django_etebase => etebase_server/django}/migrations/0002_userinfo.py (100%) rename {django_etebase => etebase_server/django}/migrations/0003_collectioninvitation.py (100%) rename {django_etebase => etebase_server/django}/migrations/0004_collectioninvitation_version.py (100%) rename {django_etebase => etebase_server/django}/migrations/0005_auto_20200526_1021.py (100%) rename {django_etebase => etebase_server/django}/migrations/0006_auto_20200526_1040.py (100%) rename {django_etebase => etebase_server/django}/migrations/0007_auto_20200526_1336.py (100%) rename {django_etebase => etebase_server/django}/migrations/0008_auto_20200526_1535.py (91%) rename {django_etebase => etebase_server/django}/migrations/0009_auto_20200526_1535.py (100%) rename {django_etebase => etebase_server/django}/migrations/0010_auto_20200526_1539.py (100%) rename {django_etebase => etebase_server/django}/migrations/0011_collectionmember_stoken.py (100%) rename {django_etebase => etebase_server/django}/migrations/0012_auto_20200527_0743.py (100%) rename {django_etebase => etebase_server/django}/migrations/0013_collectionmemberremoved.py (100%) rename {django_etebase => etebase_server/django}/migrations/0014_auto_20200602_1558.py (100%) rename {django_etebase => etebase_server/django}/migrations/0015_collectionitemrevision_salt.py (100%) rename {django_etebase => etebase_server/django}/migrations/0016_auto_20200623_0820.py (100%) rename {django_etebase => etebase_server/django}/migrations/0017_auto_20200623_0958.py (100%) rename {django_etebase => etebase_server/django}/migrations/0018_auto_20200624_0748.py (100%) rename {django_etebase => etebase_server/django}/migrations/0019_auto_20200626_0748.py (100%) rename {django_etebase => etebase_server/django}/migrations/0020_remove_collectionitemrevision_salt.py (100%) rename {django_etebase => etebase_server/django}/migrations/0021_auto_20200626_0913.py (95%) rename {django_etebase => etebase_server/django}/migrations/0022_auto_20200804_1059.py (100%) rename {django_etebase => etebase_server/django}/migrations/0023_collectionitemchunk_collection.py (100%) rename {django_etebase => etebase_server/django}/migrations/0024_auto_20200804_1209.py (100%) rename {django_etebase => etebase_server/django}/migrations/0025_auto_20200804_1216.py (100%) rename {django_etebase => etebase_server/django}/migrations/0026_auto_20200907_0752.py (100%) rename {django_etebase => etebase_server/django}/migrations/0027_auto_20200907_0752.py (100%) rename {django_etebase => etebase_server/django}/migrations/0028_auto_20200907_0754.py (95%) rename {django_etebase => etebase_server/django}/migrations/0029_auto_20200907_0801.py (100%) rename {django_etebase => etebase_server/django}/migrations/0030_auto_20200922_0832.py (100%) rename {django_etebase => etebase_server/django}/migrations/0031_auto_20201013_1336.py (100%) rename {django_etebase => etebase_server/django}/migrations/0032_auto_20201013_1409.py (100%) rename {django_etebase => etebase_server/django}/migrations/0033_collection_uid.py (100%) rename {django_etebase => etebase_server/django}/migrations/0034_auto_20201214_1124.py (100%) rename {django_etebase => etebase_server/django}/migrations/0035_auto_20201214_1126.py (100%) rename {django_etebase => etebase_server/django}/migrations/0036_auto_20201214_1128.py (100%) rename {django_etebase => etebase_server/django}/migrations/0037_auto_20210127_1237.py (100%) rename {django_etebase => etebase_server/django}/migrations/__init__.py (100%) rename {django_etebase => etebase_server/django}/models.py (100%) rename {django_etebase => etebase_server/django}/signals.py (100%) rename {django_etebase => etebase_server/django}/token_auth/__init__.py (100%) rename {django_etebase => etebase_server/django}/token_auth/apps.py (60%) rename {django_etebase => etebase_server/django}/token_auth/migrations/0001_initial.py (94%) rename {django_etebase => etebase_server/django}/token_auth/migrations/__init__.py (100%) rename {django_etebase => etebase_server/django}/token_auth/models.py (100%) rename {django_etebase => etebase_server/django}/utils.py (100%) diff --git a/README.md b/README.md index 714f8c1..e1dcdae 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ Instead of having to create Django users manually when signup up Etebase users, For example, this makes sense when putting an Etebase server in production. However, this does come with the added risk that everybody with access to your server will be able to sign up. -In order to set it up, comment out the line `ETEBASE_CREATE_USER_FUNC = "django_etebase.utils.create_user_blocked"` in `server/settings.py` and restart your Etebase server. +In order to set it up, comment out the line `ETEBASE_CREATE_USER_FUNC = "etebase_server.django.utils.create_user_blocked"` in `server/settings.py` and restart your Etebase server. # License diff --git a/django_etebase/__init__.py b/etebase_server/django/__init__.py similarity index 100% rename from django_etebase/__init__.py rename to etebase_server/django/__init__.py diff --git a/django_etebase/app_settings_inner.py b/etebase_server/django/app_settings_inner.py similarity index 100% rename from django_etebase/app_settings_inner.py rename to etebase_server/django/app_settings_inner.py diff --git a/django_etebase/apps.py b/etebase_server/django/apps.py similarity index 53% rename from django_etebase/apps.py rename to etebase_server/django/apps.py index 84e4b6e..8f95e10 100644 --- a/django_etebase/apps.py +++ b/etebase_server/django/apps.py @@ -2,4 +2,5 @@ from django.apps import AppConfig class DjangoEtebaseConfig(AppConfig): - name = "django_etebase" + name = "etebase_server.django" + label = "django_etebase" diff --git a/django_etebase/migrations/0001_initial.py b/etebase_server/django/migrations/0001_initial.py similarity index 98% rename from django_etebase/migrations/0001_initial.py rename to etebase_server/django/migrations/0001_initial.py index 42ee022..87783b3 100644 --- a/django_etebase/migrations/0001_initial.py +++ b/etebase_server/django/migrations/0001_initial.py @@ -4,7 +4,7 @@ from django.conf import settings import django.core.validators from django.db import migrations, models import django.db.models.deletion -import django_etebase.models +from etebase_server.django.models import chunk_directory_path class Migration(migrations.Migration): @@ -85,7 +85,7 @@ class Migration(migrations.Migration): ), ( "chunkFile", - models.FileField(max_length=150, unique=True, upload_to=django_etebase.models.chunk_directory_path), + models.FileField(max_length=150, unique=True, upload_to=chunk_directory_path), ), ( "item", diff --git a/django_etebase/migrations/0002_userinfo.py b/etebase_server/django/migrations/0002_userinfo.py similarity index 100% rename from django_etebase/migrations/0002_userinfo.py rename to etebase_server/django/migrations/0002_userinfo.py diff --git a/django_etebase/migrations/0003_collectioninvitation.py b/etebase_server/django/migrations/0003_collectioninvitation.py similarity index 100% rename from django_etebase/migrations/0003_collectioninvitation.py rename to etebase_server/django/migrations/0003_collectioninvitation.py diff --git a/django_etebase/migrations/0004_collectioninvitation_version.py b/etebase_server/django/migrations/0004_collectioninvitation_version.py similarity index 100% rename from django_etebase/migrations/0004_collectioninvitation_version.py rename to etebase_server/django/migrations/0004_collectioninvitation_version.py diff --git a/django_etebase/migrations/0005_auto_20200526_1021.py b/etebase_server/django/migrations/0005_auto_20200526_1021.py similarity index 100% rename from django_etebase/migrations/0005_auto_20200526_1021.py rename to etebase_server/django/migrations/0005_auto_20200526_1021.py diff --git a/django_etebase/migrations/0006_auto_20200526_1040.py b/etebase_server/django/migrations/0006_auto_20200526_1040.py similarity index 100% rename from django_etebase/migrations/0006_auto_20200526_1040.py rename to etebase_server/django/migrations/0006_auto_20200526_1040.py diff --git a/django_etebase/migrations/0007_auto_20200526_1336.py b/etebase_server/django/migrations/0007_auto_20200526_1336.py similarity index 100% rename from django_etebase/migrations/0007_auto_20200526_1336.py rename to etebase_server/django/migrations/0007_auto_20200526_1336.py diff --git a/django_etebase/migrations/0008_auto_20200526_1535.py b/etebase_server/django/migrations/0008_auto_20200526_1535.py similarity index 91% rename from django_etebase/migrations/0008_auto_20200526_1535.py rename to etebase_server/django/migrations/0008_auto_20200526_1535.py index 7bb83d5..f4b8a85 100644 --- a/django_etebase/migrations/0008_auto_20200526_1535.py +++ b/etebase_server/django/migrations/0008_auto_20200526_1535.py @@ -3,7 +3,7 @@ import django.core.validators from django.db import migrations, models import django.db.models.deletion -import django_etebase.models +from etebase_server.django.models import generate_stoken_uid class Migration(migrations.Migration): @@ -21,7 +21,7 @@ class Migration(migrations.Migration): "uid", models.CharField( db_index=True, - default=django_etebase.models.generate_stoken_uid, + default=generate_stoken_uid, max_length=43, unique=True, validators=[ diff --git a/django_etebase/migrations/0009_auto_20200526_1535.py b/etebase_server/django/migrations/0009_auto_20200526_1535.py similarity index 100% rename from django_etebase/migrations/0009_auto_20200526_1535.py rename to etebase_server/django/migrations/0009_auto_20200526_1535.py diff --git a/django_etebase/migrations/0010_auto_20200526_1539.py b/etebase_server/django/migrations/0010_auto_20200526_1539.py similarity index 100% rename from django_etebase/migrations/0010_auto_20200526_1539.py rename to etebase_server/django/migrations/0010_auto_20200526_1539.py diff --git a/django_etebase/migrations/0011_collectionmember_stoken.py b/etebase_server/django/migrations/0011_collectionmember_stoken.py similarity index 100% rename from django_etebase/migrations/0011_collectionmember_stoken.py rename to etebase_server/django/migrations/0011_collectionmember_stoken.py diff --git a/django_etebase/migrations/0012_auto_20200527_0743.py b/etebase_server/django/migrations/0012_auto_20200527_0743.py similarity index 100% rename from django_etebase/migrations/0012_auto_20200527_0743.py rename to etebase_server/django/migrations/0012_auto_20200527_0743.py diff --git a/django_etebase/migrations/0013_collectionmemberremoved.py b/etebase_server/django/migrations/0013_collectionmemberremoved.py similarity index 100% rename from django_etebase/migrations/0013_collectionmemberremoved.py rename to etebase_server/django/migrations/0013_collectionmemberremoved.py diff --git a/django_etebase/migrations/0014_auto_20200602_1558.py b/etebase_server/django/migrations/0014_auto_20200602_1558.py similarity index 100% rename from django_etebase/migrations/0014_auto_20200602_1558.py rename to etebase_server/django/migrations/0014_auto_20200602_1558.py diff --git a/django_etebase/migrations/0015_collectionitemrevision_salt.py b/etebase_server/django/migrations/0015_collectionitemrevision_salt.py similarity index 100% rename from django_etebase/migrations/0015_collectionitemrevision_salt.py rename to etebase_server/django/migrations/0015_collectionitemrevision_salt.py diff --git a/django_etebase/migrations/0016_auto_20200623_0820.py b/etebase_server/django/migrations/0016_auto_20200623_0820.py similarity index 100% rename from django_etebase/migrations/0016_auto_20200623_0820.py rename to etebase_server/django/migrations/0016_auto_20200623_0820.py diff --git a/django_etebase/migrations/0017_auto_20200623_0958.py b/etebase_server/django/migrations/0017_auto_20200623_0958.py similarity index 100% rename from django_etebase/migrations/0017_auto_20200623_0958.py rename to etebase_server/django/migrations/0017_auto_20200623_0958.py diff --git a/django_etebase/migrations/0018_auto_20200624_0748.py b/etebase_server/django/migrations/0018_auto_20200624_0748.py similarity index 100% rename from django_etebase/migrations/0018_auto_20200624_0748.py rename to etebase_server/django/migrations/0018_auto_20200624_0748.py diff --git a/django_etebase/migrations/0019_auto_20200626_0748.py b/etebase_server/django/migrations/0019_auto_20200626_0748.py similarity index 100% rename from django_etebase/migrations/0019_auto_20200626_0748.py rename to etebase_server/django/migrations/0019_auto_20200626_0748.py diff --git a/django_etebase/migrations/0020_remove_collectionitemrevision_salt.py b/etebase_server/django/migrations/0020_remove_collectionitemrevision_salt.py similarity index 100% rename from django_etebase/migrations/0020_remove_collectionitemrevision_salt.py rename to etebase_server/django/migrations/0020_remove_collectionitemrevision_salt.py diff --git a/django_etebase/migrations/0021_auto_20200626_0913.py b/etebase_server/django/migrations/0021_auto_20200626_0913.py similarity index 95% rename from django_etebase/migrations/0021_auto_20200626_0913.py rename to etebase_server/django/migrations/0021_auto_20200626_0913.py index 3bb6e21..356d5fd 100644 --- a/django_etebase/migrations/0021_auto_20200626_0913.py +++ b/etebase_server/django/migrations/0021_auto_20200626_0913.py @@ -2,7 +2,7 @@ import django.core.validators from django.db import migrations, models -import django_etebase.models +from etebase_server.django.models import generate_stoken_uid class Migration(migrations.Migration): @@ -62,7 +62,7 @@ class Migration(migrations.Migration): name="uid", field=models.CharField( db_index=True, - default=django_etebase.models.generate_stoken_uid, + default=generate_stoken_uid, max_length=43, unique=True, validators=[ diff --git a/django_etebase/migrations/0022_auto_20200804_1059.py b/etebase_server/django/migrations/0022_auto_20200804_1059.py similarity index 100% rename from django_etebase/migrations/0022_auto_20200804_1059.py rename to etebase_server/django/migrations/0022_auto_20200804_1059.py diff --git a/django_etebase/migrations/0023_collectionitemchunk_collection.py b/etebase_server/django/migrations/0023_collectionitemchunk_collection.py similarity index 100% rename from django_etebase/migrations/0023_collectionitemchunk_collection.py rename to etebase_server/django/migrations/0023_collectionitemchunk_collection.py diff --git a/django_etebase/migrations/0024_auto_20200804_1209.py b/etebase_server/django/migrations/0024_auto_20200804_1209.py similarity index 100% rename from django_etebase/migrations/0024_auto_20200804_1209.py rename to etebase_server/django/migrations/0024_auto_20200804_1209.py diff --git a/django_etebase/migrations/0025_auto_20200804_1216.py b/etebase_server/django/migrations/0025_auto_20200804_1216.py similarity index 100% rename from django_etebase/migrations/0025_auto_20200804_1216.py rename to etebase_server/django/migrations/0025_auto_20200804_1216.py diff --git a/django_etebase/migrations/0026_auto_20200907_0752.py b/etebase_server/django/migrations/0026_auto_20200907_0752.py similarity index 100% rename from django_etebase/migrations/0026_auto_20200907_0752.py rename to etebase_server/django/migrations/0026_auto_20200907_0752.py diff --git a/django_etebase/migrations/0027_auto_20200907_0752.py b/etebase_server/django/migrations/0027_auto_20200907_0752.py similarity index 100% rename from django_etebase/migrations/0027_auto_20200907_0752.py rename to etebase_server/django/migrations/0027_auto_20200907_0752.py diff --git a/django_etebase/migrations/0028_auto_20200907_0754.py b/etebase_server/django/migrations/0028_auto_20200907_0754.py similarity index 95% rename from django_etebase/migrations/0028_auto_20200907_0754.py rename to etebase_server/django/migrations/0028_auto_20200907_0754.py index 24c6246..9a0f1ae 100644 --- a/django_etebase/migrations/0028_auto_20200907_0754.py +++ b/etebase_server/django/migrations/0028_auto_20200907_0754.py @@ -2,7 +2,7 @@ from django.db import migrations -from django_etebase.models import AccessLevels +from etebase_server.django.models import AccessLevels def change_access_level_to_int(apps, schema_editor): diff --git a/django_etebase/migrations/0029_auto_20200907_0801.py b/etebase_server/django/migrations/0029_auto_20200907_0801.py similarity index 100% rename from django_etebase/migrations/0029_auto_20200907_0801.py rename to etebase_server/django/migrations/0029_auto_20200907_0801.py diff --git a/django_etebase/migrations/0030_auto_20200922_0832.py b/etebase_server/django/migrations/0030_auto_20200922_0832.py similarity index 100% rename from django_etebase/migrations/0030_auto_20200922_0832.py rename to etebase_server/django/migrations/0030_auto_20200922_0832.py diff --git a/django_etebase/migrations/0031_auto_20201013_1336.py b/etebase_server/django/migrations/0031_auto_20201013_1336.py similarity index 100% rename from django_etebase/migrations/0031_auto_20201013_1336.py rename to etebase_server/django/migrations/0031_auto_20201013_1336.py diff --git a/django_etebase/migrations/0032_auto_20201013_1409.py b/etebase_server/django/migrations/0032_auto_20201013_1409.py similarity index 100% rename from django_etebase/migrations/0032_auto_20201013_1409.py rename to etebase_server/django/migrations/0032_auto_20201013_1409.py diff --git a/django_etebase/migrations/0033_collection_uid.py b/etebase_server/django/migrations/0033_collection_uid.py similarity index 100% rename from django_etebase/migrations/0033_collection_uid.py rename to etebase_server/django/migrations/0033_collection_uid.py diff --git a/django_etebase/migrations/0034_auto_20201214_1124.py b/etebase_server/django/migrations/0034_auto_20201214_1124.py similarity index 100% rename from django_etebase/migrations/0034_auto_20201214_1124.py rename to etebase_server/django/migrations/0034_auto_20201214_1124.py diff --git a/django_etebase/migrations/0035_auto_20201214_1126.py b/etebase_server/django/migrations/0035_auto_20201214_1126.py similarity index 100% rename from django_etebase/migrations/0035_auto_20201214_1126.py rename to etebase_server/django/migrations/0035_auto_20201214_1126.py diff --git a/django_etebase/migrations/0036_auto_20201214_1128.py b/etebase_server/django/migrations/0036_auto_20201214_1128.py similarity index 100% rename from django_etebase/migrations/0036_auto_20201214_1128.py rename to etebase_server/django/migrations/0036_auto_20201214_1128.py diff --git a/django_etebase/migrations/0037_auto_20210127_1237.py b/etebase_server/django/migrations/0037_auto_20210127_1237.py similarity index 100% rename from django_etebase/migrations/0037_auto_20210127_1237.py rename to etebase_server/django/migrations/0037_auto_20210127_1237.py diff --git a/django_etebase/migrations/__init__.py b/etebase_server/django/migrations/__init__.py similarity index 100% rename from django_etebase/migrations/__init__.py rename to etebase_server/django/migrations/__init__.py diff --git a/django_etebase/models.py b/etebase_server/django/models.py similarity index 100% rename from django_etebase/models.py rename to etebase_server/django/models.py diff --git a/django_etebase/signals.py b/etebase_server/django/signals.py similarity index 100% rename from django_etebase/signals.py rename to etebase_server/django/signals.py diff --git a/django_etebase/token_auth/__init__.py b/etebase_server/django/token_auth/__init__.py similarity index 100% rename from django_etebase/token_auth/__init__.py rename to etebase_server/django/token_auth/__init__.py diff --git a/django_etebase/token_auth/apps.py b/etebase_server/django/token_auth/apps.py similarity index 60% rename from django_etebase/token_auth/apps.py rename to etebase_server/django/token_auth/apps.py index a0e98be..43ebb74 100644 --- a/django_etebase/token_auth/apps.py +++ b/etebase_server/django/token_auth/apps.py @@ -2,4 +2,4 @@ from django.apps import AppConfig class TokenAuthConfig(AppConfig): - name = "django_etebase.token_auth" + name = "etebase_server.django.token_auth" diff --git a/django_etebase/token_auth/migrations/0001_initial.py b/etebase_server/django/token_auth/migrations/0001_initial.py similarity index 94% rename from django_etebase/token_auth/migrations/0001_initial.py rename to etebase_server/django/token_auth/migrations/0001_initial.py index 660b38c..906005c 100644 --- a/django_etebase/token_auth/migrations/0001_initial.py +++ b/etebase_server/django/token_auth/migrations/0001_initial.py @@ -3,7 +3,7 @@ from django.conf import settings from django.db import migrations, models import django.db.models.deletion -from django_etebase.token_auth import models as token_auth_models +from etebase_server.django.token_auth import models as token_auth_models class Migration(migrations.Migration): diff --git a/django_etebase/token_auth/migrations/__init__.py b/etebase_server/django/token_auth/migrations/__init__.py similarity index 100% rename from django_etebase/token_auth/migrations/__init__.py rename to etebase_server/django/token_auth/migrations/__init__.py diff --git a/django_etebase/token_auth/models.py b/etebase_server/django/token_auth/models.py similarity index 100% rename from django_etebase/token_auth/models.py rename to etebase_server/django/token_auth/models.py diff --git a/django_etebase/utils.py b/etebase_server/django/utils.py similarity index 100% rename from django_etebase/utils.py rename to etebase_server/django/utils.py diff --git a/etebase_server/fastapi/dependencies.py b/etebase_server/fastapi/dependencies.py index 48894d6..b4d5cf4 100644 --- a/etebase_server/fastapi/dependencies.py +++ b/etebase_server/fastapi/dependencies.py @@ -6,8 +6,8 @@ from fastapi.security import APIKeyHeader from django.utils import timezone from django.db.models import QuerySet -from django_etebase import models -from django_etebase.token_auth.models import AuthToken, get_default_expiry +from etebase_server.django import models +from etebase_server.django.token_auth.models import AuthToken, get_default_expiry from etebase_server.myauth.models import UserType, get_typed_user_model from .exceptions import AuthenticationFailed from .utils import get_object_or_404 diff --git a/etebase_server/fastapi/main.py b/etebase_server/fastapi/main.py index 74798a4..e4abd6c 100644 --- a/etebase_server/fastapi/main.py +++ b/etebase_server/fastapi/main.py @@ -6,7 +6,7 @@ from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.trustedhost import TrustedHostMiddleware from fastapi.staticfiles import StaticFiles -from django_etebase import app_settings +from etebase_server.django import app_settings from .exceptions import CustomHttpException from .msgpack import MsgpackResponse diff --git a/etebase_server/fastapi/redis.py b/etebase_server/fastapi/redis.py index 60df6a4..c4d697c 100644 --- a/etebase_server/fastapi/redis.py +++ b/etebase_server/fastapi/redis.py @@ -1,7 +1,7 @@ import typing as t import aioredis -from django_etebase import app_settings +from etebase_server.django import app_settings class RedisWrapper: diff --git a/etebase_server/fastapi/routers/authentication.py b/etebase_server/fastapi/routers/authentication.py index b271357..d771a5c 100644 --- a/etebase_server/fastapi/routers/authentication.py +++ b/etebase_server/fastapi/routers/authentication.py @@ -14,11 +14,11 @@ from django.db import transaction from django.utils.functional import cached_property from fastapi import APIRouter, Depends, status, Request -from django_etebase import app_settings, models -from django_etebase.token_auth.models import AuthToken -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 etebase_server.django import app_settings, models +from etebase_server.django.token_auth.models import AuthToken +from etebase_server.django.models import UserInfo +from etebase_server.django.signals import user_signed_up +from etebase_server.django.utils import create_user, get_user_queryset, CallbackContext from etebase_server.myauth.models import UserType, get_typed_user_model from ..exceptions import AuthenticationFailed, transform_validation_error, HttpError from ..msgpack import MsgpackRoute diff --git a/etebase_server/fastapi/routers/collection.py b/etebase_server/fastapi/routers/collection.py index 3c2e511..6722c78 100644 --- a/etebase_server/fastapi/routers/collection.py +++ b/etebase_server/fastapi/routers/collection.py @@ -7,7 +7,7 @@ from django.db import transaction, IntegrityError from django.db.models import Q, QuerySet from fastapi import APIRouter, Depends, status, Request, BackgroundTasks -from django_etebase import models +from etebase_server.django import models from etebase_server.myauth.models import UserType from .authentication import get_authenticated_user from .websocket import get_ticket, TicketRequest, TicketOut diff --git a/etebase_server/fastapi/routers/invitation.py b/etebase_server/fastapi/routers/invitation.py index 2ab2f64..adb51c6 100644 --- a/etebase_server/fastapi/routers/invitation.py +++ b/etebase_server/fastapi/routers/invitation.py @@ -4,8 +4,8 @@ from django.db import transaction, IntegrityError from django.db.models import QuerySet from fastapi import APIRouter, Depends, status, Request -from django_etebase import models -from django_etebase.utils import get_user_queryset, CallbackContext +from etebase_server.django import models +from etebase_server.django.utils import get_user_queryset, CallbackContext from etebase_server.myauth.models import UserType, get_typed_user_model from .authentication import get_authenticated_user from ..exceptions import HttpError, PermissionDenied diff --git a/etebase_server/fastapi/routers/member.py b/etebase_server/fastapi/routers/member.py index dff95c1..123357b 100644 --- a/etebase_server/fastapi/routers/member.py +++ b/etebase_server/fastapi/routers/member.py @@ -4,7 +4,7 @@ from django.db import transaction from django.db.models import QuerySet from fastapi import APIRouter, Depends, status -from django_etebase import models +from etebase_server.django import models from etebase_server.myauth.models import UserType, get_typed_user_model from .authentication import get_authenticated_user from ..msgpack import MsgpackRoute diff --git a/etebase_server/fastapi/routers/test_reset_view.py b/etebase_server/fastapi/routers/test_reset_view.py index a66d1cc..7895697 100644 --- a/etebase_server/fastapi/routers/test_reset_view.py +++ b/etebase_server/fastapi/routers/test_reset_view.py @@ -3,7 +3,7 @@ from django.db import transaction 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_server.django.utils import get_user_queryset, CallbackContext from .authentication import SignupIn, signup_save from ..msgpack import MsgpackRoute from ..exceptions import HttpError diff --git a/etebase_server/fastapi/routers/websocket.py b/etebase_server/fastapi/routers/websocket.py index 19cd5e1..019f58f 100644 --- a/etebase_server/fastapi/routers/websocket.py +++ b/etebase_server/fastapi/routers/websocket.py @@ -8,8 +8,8 @@ from fastapi import APIRouter, Depends, WebSocket, WebSocketDisconnect, status import nacl.encoding import nacl.utils -from django_etebase import models -from django_etebase.utils import CallbackContext, get_user_queryset +from etebase_server.django import models +from etebase_server.django.utils import CallbackContext, get_user_queryset from etebase_server.myauth.models import UserType, get_typed_user_model from ..dependencies import get_collection_queryset, get_item_queryset diff --git a/etebase_server/fastapi/stoken_handler.py b/etebase_server/fastapi/stoken_handler.py index b6f2999..b4c7eab 100644 --- a/etebase_server/fastapi/stoken_handler.py +++ b/etebase_server/fastapi/stoken_handler.py @@ -3,7 +3,7 @@ import typing as t from django.db.models import QuerySet from fastapi import status -from django_etebase.models import Stoken +from etebase_server.django.models import Stoken from .exceptions import HttpError diff --git a/etebase_server/fastapi/utils.py b/etebase_server/fastapi/utils.py index b215477..334633c 100644 --- a/etebase_server/fastapi/utils.py +++ b/etebase_server/fastapi/utils.py @@ -10,8 +10,8 @@ from pydantic import BaseModel as PyBaseModel from django.db.models import Model, QuerySet from django.core.exceptions import ObjectDoesNotExist -from django_etebase import app_settings -from django_etebase.models import AccessLevels +from etebase_server.django import app_settings +from etebase_server.django.models import AccessLevels from etebase_server.myauth.models import UserType, get_typed_user_model from .exceptions import HttpError, HttpErrorOut diff --git a/etebase_server/settings.py b/etebase_server/settings.py index f1db11e..5ef89e3 100644 --- a/etebase_server/settings.py +++ b/etebase_server/settings.py @@ -55,8 +55,8 @@ INSTALLED_APPS = [ "django.contrib.messages", "django.contrib.staticfiles", "etebase_server.myauth.apps.MyauthConfig", - "django_etebase.apps.DjangoEtebaseConfig", - "django_etebase.token_auth.apps.TokenAuthConfig", + "etebase_server.django.apps.DjangoEtebaseConfig", + "etebase_server.django.token_auth.apps.TokenAuthConfig", ] MIDDLEWARE = [ @@ -167,7 +167,7 @@ if any(os.path.isfile(x) for x in config_locations): if "database-options" in config: DATABASES["default"]["OPTIONS"] = config["database-options"] -ETEBASE_CREATE_USER_FUNC = "django_etebase.utils.create_user_blocked" +ETEBASE_CREATE_USER_FUNC = "etebase_server.django.utils.create_user_blocked" # Efficient file streaming (for large files) SENDFILE_BACKEND = "etebase_fastapi.sendfile.backends.simple" From 791de952f48b5ff2c22483b4327b00cc02cf5412 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sun, 8 May 2022 18:15:21 +0200 Subject: [PATCH 4/5] fix: move template directory into source directory This is in preparation for creating a python package. --- etebase_server/settings.py | 5 +++-- {templates => etebase_server/templates}/success.html | 0 2 files changed, 3 insertions(+), 2 deletions(-) rename {templates => etebase_server/templates}/success.html (100%) diff --git a/etebase_server/settings.py b/etebase_server/settings.py index 5ef89e3..185a199 100644 --- a/etebase_server/settings.py +++ b/etebase_server/settings.py @@ -15,7 +15,8 @@ import configparser from .utils import get_secret_from_file # Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +SOURCE_DIR = os.path.dirname(os.path.abspath(__file__)) +BASE_DIR = os.path.dirname(SOURCE_DIR) AUTH_USER_MODEL = "myauth.User" @@ -74,7 +75,7 @@ ROOT_URLCONF = "etebase_server.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [os.path.join(BASE_DIR, "templates")], + "DIRS": [os.path.join(SOURCE_DIR, "templates")], "APP_DIRS": True, "OPTIONS": { "context_processors": [ diff --git a/templates/success.html b/etebase_server/templates/success.html similarity index 100% rename from templates/success.html rename to etebase_server/templates/success.html From aac27e6a4367d69a38a8a9b4ea5491524f35f019 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sun, 8 May 2022 15:33:12 +0200 Subject: [PATCH 5/5] feat: create python package --- .gitignore | 4 ++++ pyproject.toml | 6 +++++- setup.py | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 2c3f6a9..590be07 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,7 @@ __pycache__ /etebase_server_settings.py /secret.txt + +/build +/dist +/*.egg-info diff --git a/pyproject.toml b/pyproject.toml index e34796e..b622800 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,6 @@ [tool.black] -line-length = 120 \ No newline at end of file +line-length = 120 + +[build-system] +requires = ["setuptools>=42"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c7bd106 --- /dev/null +++ b/setup.py @@ -0,0 +1,20 @@ +from setuptools import find_packages, setup + +setup( + name='etebase_server', + version='0.8.3', + description='An Etebase (EteSync 2.0) server', + url='https://www.etebase.com/', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Framework :: Django', + 'Framework :: FastAPI', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: GNU Affero General Public License v3', + ], + packages=find_packages(include=['etebase_server', 'etebase_server.*']), + install_requires=list(open('requirements.in/base.txt')), + package_data={ + 'etebase_server': ['templates/*'], + } +)