mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 23:17:09 +00:00
Merge branch 'master' of https://gitlab.prodcontest.ru/team-15/project
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
@@ -30,3 +30,13 @@ class Command(BaseCommand):
|
||||
slug="welcome",
|
||||
icon=welcome_icon,
|
||||
)
|
||||
|
||||
if not Achievement.objects.filter(slug="start_competition").exists():
|
||||
with open(f"{icons_dir}/start_competition.png", "rb") as f:
|
||||
start_competition = File(f, name="start_competition.png")
|
||||
Achievement.objects.get_or_create(
|
||||
name="Да начнётся битва!",
|
||||
description="Начните соревнование",
|
||||
slug="start_competition",
|
||||
icon=start_competition,
|
||||
)
|
||||
|
||||
@@ -5,3 +5,6 @@ class CompetitionsConfig(AppConfig):
|
||||
name = "apps.competition"
|
||||
label = "competition"
|
||||
verbose_name = "Соревнование"
|
||||
|
||||
def ready(self):
|
||||
import apps.competition.signals
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
from apps.achievement.models import Achievement, UserAchievement
|
||||
from apps.competition.models import State
|
||||
from apps.user.models import User
|
||||
|
||||
|
||||
@receiver(post_save, sender=State)
|
||||
def assign_start_competition_achievement(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
if State.objects.filter(user=instance.user, state=State.StateChoices.STARTED.value).count() == 1 \
|
||||
and not State.objects.filter(user=instance.user, state=State.StateChoices.FINISHED.value).exists():
|
||||
start_competition_achievement = Achievement.objects.get(slug="start_competition")
|
||||
UserAchievement.objects.create(
|
||||
user=instance.user, achievement=start_competition_achievement
|
||||
)
|
||||
Reference in New Issue
Block a user