From cc4359e549fc7a72f6d9d95d275437a24d7ec0ce Mon Sep 17 00:00:00 2001 From: webn1nja Date: Tue, 1 Oct 2024 18:41:32 +0300 Subject: [PATCH 1/3] games button removed; game signals disabled --- adaptive_hockey_federation/games/signals.py | 119 ++++++++--------- .../templates/base/drawer.html | 122 +++++++++--------- 2 files changed, 121 insertions(+), 120 deletions(-) diff --git a/adaptive_hockey_federation/games/signals.py b/adaptive_hockey_federation/games/signals.py index 711b8f98..e97a6591 100644 --- a/adaptive_hockey_federation/games/signals.py +++ b/adaptive_hockey_federation/games/signals.py @@ -1,59 +1,60 @@ -from django.db.models.signals import post_save -from django.dispatch import receiver - -from games.models import Game, GamePlayer, GameTeam - -from main.models import Player, Team - - -@receiver(post_save, sender=Game, dispatch_uid="unique_signal") -def create_game_teams(sender, instance, created, **kwargs): - """ - Сигнал для автоматического создания GameTeam при создании Game. - - Для последующего использования сигнала при обновлении объекта Game - реализовано удаление старых GameTeam, которые ссылались на этот Game. - """ - queryset_teams = list( - map(lambda x: Team.objects.get(id=x), instance.teams), - ) - GameTeam.objects.filter(game=instance).delete() - for team in queryset_teams: - game_team = GameTeam( - id=team.id, - name=team.name, - discipline_name=team.discipline_name.name, - game=instance, - ) - game_team.players = Player.objects.filter( - team=team, - ) - game_team.save() - - # TODO необходимо пересмотреть логику создания объекта игры, - # конкретно изменение - # номеров игроков. Оно должно происходить до того - # как объект игры попадёт в бд. - # TODO отправлять видео на распознавание до изменения номеров игроков - # нелогично. - # if created and instance.video_link: - # send_game_video_to_process(instance.id) - - -@receiver(post_save, sender=GameTeam, dispatch_uid="unique_signal") -def create_game_players(sender, instance, created, **kwargs): - """Сигнал для автоматического создания GamePlayer при создании GameTeam.""" - if created: - queryset_players = instance.players - all_players = [] - for player in queryset_players: - game_player = GamePlayer( - id=player.id, - name=player.name, - last_name=player.surname, - patronymic=player.patronymic, - number=player.number, - game_team=instance, - ) - all_players.append(game_player) - GamePlayer.objects.bulk_create(all_players) +# from django.db.models.signals import post_save +# from django.dispatch import receiver + +# from games.models import Game, GamePlayer, GameTeam + +# from main.models import Player, Team + + +# @receiver(post_save, sender=Game, dispatch_uid="unique_signal") +# def create_game_teams(sender, instance, created, **kwargs): +# """ +# Сигнал для автоматического создания GameTeam при создании Game. + +# Для последующего использования сигнала при обновлении объекта Game +# реализовано удаление старых GameTeam, которые ссылались на этот Game. +# """ +# queryset_teams = list( +# map(lambda x: Team.objects.get(id=x), instance.teams), +# ) +# GameTeam.objects.filter(game=instance).delete() +# for team in queryset_teams: +# game_team = GameTeam( +# id=team.id, +# name=team.name, +# discipline_name=team.discipline_name.name, +# game=instance, +# ) +# game_team.players = Player.objects.filter( +# team=team, +# ) +# game_team.save() + +# # TODO необходимо пересмотреть логику создания объекта игры, +# # конкретно изменение +# # номеров игроков. Оно должно происходить до того +# # как объект игры попадёт в бд. +# # TODO отправлять видео на распознавание до изменения номеров игроков +# # нелогично. +# # if created and instance.video_link: +# # send_game_video_to_process(instance.id) + + +# @receiver(post_save, sender=GameTeam, dispatch_uid="unique_signal") +# def create_game_players(sender, instance, created, **kwargs): +# """Сигнал для автоматического создания +# GamePlayer при создании GameTeam.""" +# if created: +# queryset_players = instance.players +# all_players = [] +# for player in queryset_players: +# game_player = GamePlayer( +# id=player.id, +# name=player.name, +# last_name=player.surname, +# patronymic=player.patronymic, +# number=player.number, +# game_team=instance, +# ) +# all_players.append(game_player) +# GamePlayer.objects.bulk_create(all_players) diff --git a/adaptive_hockey_federation/templates/base/drawer.html b/adaptive_hockey_federation/templates/base/drawer.html index b09cf267..be559fbd 100644 --- a/adaptive_hockey_federation/templates/base/drawer.html +++ b/adaptive_hockey_federation/templates/base/drawer.html @@ -1,61 +1,61 @@ -{% if not request.user.is_moderator %} - -{% endif %} +{% if not request.user.is_moderator %} + +{% endif %} From fb6dd59804eb4c319b66f5e7ceba59fedf4ed71f Mon Sep 17 00:00:00 2001 From: webn1nja Date: Thu, 3 Oct 2024 17:16:53 +0300 Subject: [PATCH 2/3] games signals and button deleted --- adaptive_hockey_federation/games/apps.py | 24 +++----- adaptive_hockey_federation/games/signals.py | 60 ------------------- .../templates/base/drawer.html | 5 -- 3 files changed, 9 insertions(+), 80 deletions(-) delete mode 100644 adaptive_hockey_federation/games/signals.py diff --git a/adaptive_hockey_federation/games/apps.py b/adaptive_hockey_federation/games/apps.py index a2928abf..4c1a526b 100644 --- a/adaptive_hockey_federation/games/apps.py +++ b/adaptive_hockey_federation/games/apps.py @@ -1,15 +1,9 @@ -from django.apps import AppConfig - - -class GamesConfig(AppConfig): - """Класс-конфигуратор для приложения games.""" - - default_auto_field = "django.db.models.BigAutoField" - name = "games" - verbose_name = "Игры" - - def ready(self) -> None: - """Импортирование сигналов для приложения.""" - import games.signals # noqa - - return super().ready() +from django.apps import AppConfig + + +class GamesConfig(AppConfig): + """Класс-конфигуратор для приложения games.""" + + default_auto_field = "django.db.models.BigAutoField" + name = "games" + verbose_name = "Игры" diff --git a/adaptive_hockey_federation/games/signals.py b/adaptive_hockey_federation/games/signals.py deleted file mode 100644 index e97a6591..00000000 --- a/adaptive_hockey_federation/games/signals.py +++ /dev/null @@ -1,60 +0,0 @@ -# from django.db.models.signals import post_save -# from django.dispatch import receiver - -# from games.models import Game, GamePlayer, GameTeam - -# from main.models import Player, Team - - -# @receiver(post_save, sender=Game, dispatch_uid="unique_signal") -# def create_game_teams(sender, instance, created, **kwargs): -# """ -# Сигнал для автоматического создания GameTeam при создании Game. - -# Для последующего использования сигнала при обновлении объекта Game -# реализовано удаление старых GameTeam, которые ссылались на этот Game. -# """ -# queryset_teams = list( -# map(lambda x: Team.objects.get(id=x), instance.teams), -# ) -# GameTeam.objects.filter(game=instance).delete() -# for team in queryset_teams: -# game_team = GameTeam( -# id=team.id, -# name=team.name, -# discipline_name=team.discipline_name.name, -# game=instance, -# ) -# game_team.players = Player.objects.filter( -# team=team, -# ) -# game_team.save() - -# # TODO необходимо пересмотреть логику создания объекта игры, -# # конкретно изменение -# # номеров игроков. Оно должно происходить до того -# # как объект игры попадёт в бд. -# # TODO отправлять видео на распознавание до изменения номеров игроков -# # нелогично. -# # if created and instance.video_link: -# # send_game_video_to_process(instance.id) - - -# @receiver(post_save, sender=GameTeam, dispatch_uid="unique_signal") -# def create_game_players(sender, instance, created, **kwargs): -# """Сигнал для автоматического создания -# GamePlayer при создании GameTeam.""" -# if created: -# queryset_players = instance.players -# all_players = [] -# for player in queryset_players: -# game_player = GamePlayer( -# id=player.id, -# name=player.name, -# last_name=player.surname, -# patronymic=player.patronymic, -# number=player.number, -# game_team=instance, -# ) -# all_players.append(game_player) -# GamePlayer.objects.bulk_create(all_players) diff --git a/adaptive_hockey_federation/templates/base/drawer.html b/adaptive_hockey_federation/templates/base/drawer.html index be559fbd..5037bf2e 100644 --- a/adaptive_hockey_federation/templates/base/drawer.html +++ b/adaptive_hockey_federation/templates/base/drawer.html @@ -41,11 +41,6 @@ {% url 'unloads:unloads' as url_name %}{% include "base/button.html" with name="Выгрузки" %} {% endif %} - {% comment %} {% if not request.user.is_agent %} - - {% endif %} {% endcomment %}