From d50e391d16f56512fa5fada33f910dba97db1ccb Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 3 Dec 2024 16:03:06 +0100 Subject: [PATCH] cleanup --- api/urls.py | 4 ++-- padelclub_backend/asgi.py | 2 +- padelclub_backend/urls.py | 2 -- {tournaments => sync}/consumers.py | 0 sync/registry.py | 2 +- {tournaments => sync}/routing.py | 0 sync/signals.py | 4 ++-- sync/views.py | 6 +++--- tournaments/views.py | 10 +++++----- 9 files changed, 14 insertions(+), 16 deletions(-) rename {tournaments => sync}/consumers.py (100%) rename {tournaments => sync}/routing.py (100%) diff --git a/api/urls.py b/api/urls.py index eb5a65c..afff73d 100644 --- a/api/urls.py +++ b/api/urls.py @@ -3,7 +3,7 @@ from rest_framework import routers from rest_framework.authtoken.views import obtain_auth_token from . import views -from sync.views import DataApi, DataAccessViewSet +from sync.views import SynchronizationApi, DataAccessViewSet router = routers.DefaultRouter() router.register(r'users', views.UserViewSet) @@ -27,7 +27,7 @@ router.register(r'data-access', DataAccessViewSet) urlpatterns = [ path('', include(router.urls)), - path('data/', DataApi.as_view(), name="data"), + path('data/', SynchronizationApi.as_view(), name="data"), path('api-token-auth/', obtain_auth_token, name='api_token_auth'), path("user-by-token/", views.user_by_token, name="user_by_token"), diff --git a/padelclub_backend/asgi.py b/padelclub_backend/asgi.py index 00fb082..357c7c2 100644 --- a/padelclub_backend/asgi.py +++ b/padelclub_backend/asgi.py @@ -18,7 +18,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "padelclub_backend.settings") django_asgi_app = get_asgi_application() -from tournaments.routing import websocket_urlpatterns +from sync.routing import websocket_urlpatterns application = ProtocolTypeRouter( { diff --git a/padelclub_backend/urls.py b/padelclub_backend/urls.py index 660b4bb..12abeb1 100644 --- a/padelclub_backend/urls.py +++ b/padelclub_backend/urls.py @@ -18,12 +18,10 @@ from django.urls import include, path urlpatterns = [ - # path('roads/', include(router.urls)), path("", include("tournaments.urls")), path('roads/', include("api.urls")), path('kingdom/', admin.site.urls), path('api-auth/', include('rest_framework.urls')), - path('dj-auth/', include('django.contrib.auth.urls')), ] diff --git a/tournaments/consumers.py b/sync/consumers.py similarity index 100% rename from tournaments/consumers.py rename to sync/consumers.py diff --git a/sync/registry.py b/sync/registry.py index 1ff797b..0a3af6d 100644 --- a/sync/registry.py +++ b/sync/registry.py @@ -27,7 +27,7 @@ class SyncRegistry: return True def register(self, model): - print(f'>>> Registers {model.__name__}') + # print(f'>>> Registers {model.__name__}') self._registry[model.__name__] = model def get_model(self, model_name): diff --git a/tournaments/routing.py b/sync/routing.py similarity index 100% rename from tournaments/routing.py rename to sync/routing.py diff --git a/sync/signals.py b/sync/signals.py index 41845ae..33eaeda 100644 --- a/sync/signals.py +++ b/sync/signals.py @@ -9,7 +9,7 @@ from channels.layers import get_channel_layer from asgiref.sync import async_to_sync from threading import Timer -from functools import partial +# from functools import partial # Synchronization @@ -117,7 +117,7 @@ def save_model_log(users, model_operation, model_name, model_id, store_id): def related_data_access(instance): related_instances = instance.related_instances() - related_ids = [ri.id for ri in instance.related_instances()] + related_ids = [ri.id for ri in related_instances] related_ids.append(instance.id) return DataAccess.objects.filter(model_id__in=related_ids) diff --git a/sync/views.py b/sync/views.py index a9b5535..86dd28c 100644 --- a/sync/views.py +++ b/sync/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render +# from django.shortcuts import render from .serializers import DataAccessSerializer from django.db.models import Q @@ -8,7 +8,7 @@ from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework import status -from django.apps import apps +# from django.apps import apps from django.utils import timezone from django.core.exceptions import ObjectDoesNotExist @@ -21,7 +21,7 @@ from .models import ModelLog, BaseModel, SideStoreModel, DataAccess from .registry import sync_registry -class DataApi(APIView): +class SynchronizationApi(APIView): permission_classes = [IsAuthenticated] def post(self, request, *args, **kwargs): diff --git a/tournaments/views.py b/tournaments/views.py index 69826dd..8c7f799 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -1,19 +1,19 @@ from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse from django.utils.encoding import force_str -from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode +from django.utils.http import urlsafe_base64_decode from django.urls import reverse from tournaments.models.device_token import DeviceToken # from tournaments.models import group_stage from .models import Court, DateInterval, Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamScore, TeamRegistration, PlayerRegistration, Purchase, FailedApiCall -from .models import TeamSummon -from datetime import datetime, timedelta +# from .models import TeamSummon +from datetime import timedelta -from django.template import loader +# from django.template import loader from datetime import date -from django.http import JsonResponse +# from django.http import JsonResponse from django.db.models import Q import json import asyncio