-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
games button removed; game signals disabled #555
Merged
KonstantinRaikhert
merged 5 commits into
dev
from
bugfix/remove_games_button_and_signals
Oct 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cc4359e
games button removed; game signals disabled
webn1nja fb6dd59
games signals and button deleted
webn1nja e8a5a20
returned the signals file so that there would be no conflict during t…
webn1nja 389a128
Merge branch 'dev' into bugfix/remove_games_button_and_signals
webn1nja 82f3619
fix ruff
KonstantinRaikhert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
{% if not request.user.is_moderator %} | ||
<aside id="container__fluid" class="aside-navbar"> | ||
<div class="navbar-container"> | ||
<ul class="navigate"> | ||
<div class="py-5 logo-zone"> | ||
<div class="col-auto flex justify-end"> | ||
<span class="logo-img"> | ||
<img src="https://paraicehockey.ru/wp-content/uploads/2022/02/FAH_q.png" width="100" height="100"> | ||
</span> | ||
</div> | ||
<div class="col text-white flex justify-start"> | ||
Мир хоккея<br>для особенных<br>детей | ||
</div> | ||
</div> | ||
{% if not request.user.is_agent %} | ||
<li class="nav-item py-2 list-group"> | ||
{% url 'main:players' as url_name %}{% include "base/button.html" with name="Игроки" %} | ||
</li> | ||
<li class="nav-item py-2"> | ||
{% url 'users:users' as url_name %}{% include "base/button.html" with name="Пользователи" %} | ||
</li> | ||
{% endif %} | ||
<li class="nav-item py-2"> | ||
{% url 'main:teams' as url_name %}{% include "base/button.html" with name="Команды" %} | ||
</li> | ||
{% if not request.user.is_agent %} | ||
<li class="nav-item py-2"> | ||
{% url 'main:staffs' as url_name %}{% include "base/button.html" with name="Персонал команд" %} | ||
</li> | ||
{% endif %} | ||
<li class="nav-item py-2"> | ||
{% url 'competitions:competitions' as url_name %}{% include "base/button.html" with name="Соревнования" %} | ||
</li> | ||
{% if not request.user.is_agent %} | ||
<li class="nav-item py-2"> | ||
{% url 'analytics:analytics' as url_name %}{% include "base/button.html" with name="Аналитика" %} | ||
</li> | ||
{% endif %} | ||
{% if request.user.is_admin %} | ||
<li class="nav-item py-2"> | ||
{% url 'unloads:unloads' as url_name %}{% include "base/button.html" with name="Выгрузки" %} | ||
</li> | ||
{% endif %} | ||
{% if not request.user.is_agent %} | ||
<li class="nav-item py-2"> | ||
{% url 'games:games' as url_name %}{% include "base/button.html" with name="Игры" %} | ||
</li> | ||
{% endif %} | ||
</ul> | ||
<button | ||
onclick="toggle_visibility(false);" | ||
class="nav-button" | ||
type="button" | ||
aria-controls="staticBackdrop" | ||
aria-expanded="true" | ||
> | ||
{% include "base/triangle.html" %} | ||
</button> | ||
</div> | ||
</aside> | ||
{% endif %} | ||
{% if not request.user.is_moderator %} | ||
<aside id="container__fluid" class="aside-navbar"> | ||
<div class="navbar-container"> | ||
<ul class="navigate"> | ||
<div class="py-5 logo-zone"> | ||
<div class="col-auto flex justify-end"> | ||
<span class="logo-img"> | ||
<img src="https://paraicehockey.ru/wp-content/uploads/2022/02/FAH_q.png" width="100" height="100"> | ||
</span> | ||
</div> | ||
<div class="col text-white flex justify-start"> | ||
Мир хоккея<br>для особенных<br>детей | ||
</div> | ||
</div> | ||
{% if not request.user.is_agent %} | ||
<li class="nav-item py-2 list-group"> | ||
{% url 'main:players' as url_name %}{% include "base/button.html" with name="Игроки" %} | ||
</li> | ||
<li class="nav-item py-2"> | ||
{% url 'users:users' as url_name %}{% include "base/button.html" with name="Пользователи" %} | ||
</li> | ||
{% endif %} | ||
<li class="nav-item py-2"> | ||
{% url 'main:teams' as url_name %}{% include "base/button.html" with name="Команды" %} | ||
</li> | ||
{% if not request.user.is_agent %} | ||
<li class="nav-item py-2"> | ||
{% url 'main:staffs' as url_name %}{% include "base/button.html" with name="Персонал команд" %} | ||
</li> | ||
{% endif %} | ||
<li class="nav-item py-2"> | ||
{% url 'competitions:competitions' as url_name %}{% include "base/button.html" with name="Соревнования" %} | ||
</li> | ||
{% if not request.user.is_agent %} | ||
<li class="nav-item py-2"> | ||
{% url 'analytics:analytics' as url_name %}{% include "base/button.html" with name="Аналитика" %} | ||
</li> | ||
{% endif %} | ||
{% if request.user.is_admin %} | ||
<li class="nav-item py-2"> | ||
{% url 'unloads:unloads' as url_name %}{% include "base/button.html" with name="Выгрузки" %} | ||
</li> | ||
{% endif %} | ||
{% comment %} {% if not request.user.is_agent %} | ||
<li class="nav-item py-2"> | ||
{% url 'games:games' as url_name %}{% include "base/button.html" with name="Игры" %} | ||
</li> | ||
{% endif %} {% endcomment %} | ||
</ul> | ||
<button | ||
onclick="toggle_visibility(false);" | ||
class="nav-button" | ||
type="button" | ||
aria-controls="staticBackdrop" | ||
aria-expanded="true" | ||
> | ||
{% include "base/triangle.html" %} | ||
</button> | ||
</div> | ||
</aside> | ||
{% endif %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Наверно можно сейчас и удалить все что касается игр. а в остальном мержим
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все сделал, давайте мерджить