mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 17:57:10 +00:00
feat: added competition logic
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.1.6 on 2025-02-28 22:40
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('competition', '0001_initial'),
|
||||
('user', '0002_user_status'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='competition',
|
||||
name='participants',
|
||||
field=models.ManyToManyField(related_name='participants', to='user.user'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,28 @@
|
||||
# Generated by Django 5.1.6 on 2025-02-28 23:26
|
||||
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('competition', '0002_competition_participants'),
|
||||
('user', '0003_alter_user_status'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='State',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('state', models.CharField(choices=[('not_started', 'Not Started'), ('started', 'Started'), ('finished', 'Finished')], max_length=11)),
|
||||
('competition', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='competition.competition')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.user')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -1,18 +1,18 @@
|
||||
from django.db import models
|
||||
|
||||
from apps.core.models import BaseModel
|
||||
|
||||
|
||||
class CompetitionType(models.TextChoices):
|
||||
SOLO = "solo"
|
||||
|
||||
|
||||
class CompetitionParticipationType(models.TextChoices):
|
||||
EDU = "edu"
|
||||
COMPETITIVE = "competitive"
|
||||
|
||||
from apps.user.models import User
|
||||
|
||||
class Competition(BaseModel):
|
||||
class CompetitionType(models.TextChoices):
|
||||
SOLO = "solo"
|
||||
|
||||
|
||||
class CompetitionParticipationType(models.TextChoices):
|
||||
EDU = "edu"
|
||||
COMPETITIVE = "competitive"
|
||||
|
||||
|
||||
title = models.CharField(max_length=100, verbose_name="Название")
|
||||
description = models.TextField(verbose_name="Описание")
|
||||
image_url = models.FileField(
|
||||
@@ -34,7 +34,19 @@ class Competition(BaseModel):
|
||||
choices=CompetitionParticipationType.choices,
|
||||
verbose_name="Тип соревнования",
|
||||
)
|
||||
participants = models.ManyToManyField(User, related_name="participants")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "соревнование"
|
||||
verbose_name_plural = "соревнования"
|
||||
|
||||
|
||||
class State(BaseModel):
|
||||
class StateChoices(models.TextChoices):
|
||||
NOT_STARTED = 'not_started'
|
||||
STARTED = 'started'
|
||||
FINISHED = 'finished'
|
||||
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
competition = models.ForeignKey(Competition, on_delete=models.CASCADE)
|
||||
state = models.CharField(choices=StateChoices.choices, max_length=11)
|
||||
Reference in New Issue
Block a user