diff --git a/sync/signals.py b/sync/signals.py index 221c2ce..58b2521 100644 --- a/sync/signals.py +++ b/sync/signals.py @@ -126,15 +126,17 @@ def save_model_log(users, model_operation, model_name, model_id, store_id): with transaction.atomic(): for user in users: - if user.should_synchronize: - model_log = ModelLog() - model_log.user = user - model_log.operation = model_operation - model_log.model_name = model_name - model_log.model_id = model_id - model_log.store_id = store_id - model_log.device_id = device_id - model_log.save() + print(f'>>> create log for {user.username} : {model_operation} {model_name}') + + # if user.should_synchronize: + model_log = ModelLog() + model_log.user = user + model_log.operation = model_operation + model_log.model_name = model_name + model_log.model_id = model_id + model_log.store_id = store_id + model_log.device_id = device_id + model_log.save() # print(f'ML users = {len(users)}') # existing_log = ModelLog.objects.filter(users__in=users, model_id=model_id, operation=model_operation).first() @@ -249,6 +251,7 @@ def related_users(instance): # look in hierarchy related_instances = instance.related_instances() + print(f'related_instances = {related_instances}') related_users = [ri.related_user for ri in related_instances if isinstance(ri, BaseModel)] users.update(related_users) diff --git a/sync/views.py b/sync/views.py index cde9abc..787e286 100644 --- a/sync/views.py +++ b/sync/views.py @@ -106,7 +106,7 @@ class SynchronizationApi(HierarchyApiView): data = op.get('data') data_id = data.get('id') device_registry.register(data_id, device_id) - print(f'*** 1count = {device_registry.count()}') + # print(f'*** 1count = {device_registry.count()}') try: print(f'{model_operation} : {model_name}, id = {data['id']}') diff --git a/tournaments/services/tournament_registration.py b/tournaments/services/tournament_registration.py index 6d01eb9..0233edb 100644 --- a/tournaments/services/tournament_registration.py +++ b/tournaments/services/tournament_registration.py @@ -6,6 +6,7 @@ from django.contrib import messages from ..utils.licence_validator import LicenseValidator from ..utils.player_search import get_player_name_from_csv from tournaments.models import PlayerRegistration +from ..utils.extensions import is_not_sqlite_backend class TournamentRegistrationService: def __init__(self, request, tournament): @@ -99,12 +100,13 @@ class TournamentRegistrationService: self.context['team_form'].cleaned_data ) - self.email_service.send_registration_confirmation( - self.request, - self.tournament, - team_registration, - waiting_list_position - ) + if is_not_sqlite_backend(): + self.email_service.send_registration_confirmation( + self.request, + self.tournament, + team_registration, + waiting_list_position + ) self.clear_session_data() self.context['registration_successful'] = True diff --git a/tournaments/signals.py b/tournaments/signals.py index ae6cbd1..48859cb 100644 --- a/tournaments/signals.py +++ b/tournaments/signals.py @@ -15,6 +15,8 @@ from tournaments.models import PlayerDataSource from shared.discord import send_discord_log_message, send_discord_failed_calls_message from datetime import datetime +from .utils.extensions import is_not_sqlite_backend + def generate_unique_code(): characters = string.ascii_lowercase + string.digits while True: @@ -64,7 +66,8 @@ def notify_team(team, tournament, message_type): if tournament.supposedly_in_progress(): return - TournamentEmailService.notify_team(team, tournament, message_type) + if is_not_sqlite_backend(): + TournamentEmailService.notify_team(team, tournament, message_type) @receiver(pre_delete, sender=TeamRegistration) def unregister_team(sender, instance, **kwargs): diff --git a/tournaments/utils/extensions.py b/tournaments/utils/extensions.py index 2b30e90..fed47b1 100644 --- a/tournaments/utils/extensions.py +++ b/tournaments/utils/extensions.py @@ -1,4 +1,5 @@ import uuid +from django.conf import settings def format_seconds(seconds): hours = int(seconds / 3600) @@ -14,3 +15,7 @@ def plural_format(label, count): def create_random_filename(base_name, extension): random_string = str(uuid.uuid4()) return f"{base_name}_{random_string}.{extension}" + +def is_not_sqlite_backend(): + default_db_engine = settings.DATABASES['default']['ENGINE'] + return default_db_engine != 'django.db.backends.sqlite3' diff --git a/tournaments/views.py b/tournaments/views.py index f18a369..1679a84 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -833,7 +833,7 @@ def my_tournaments(request): def filter_user_tournaments(tournaments): return [t for t in tournaments if t.team_registrations.filter( - playerregistration__licence_id__icontains=stripped_license, + player_registrations__licence_id__icontains=stripped_license, walk_out=False ).exists()]