parent
3326eae98b
commit
e5ec7efc5b
Binary file not shown.
@ -0,0 +1,41 @@ |
||||
# Generated by Django 5.1 on 2024-12-13 14:18 |
||||
|
||||
import django.db.models.deletion |
||||
import django.utils.timezone |
||||
from django.conf import settings |
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('tournaments', '0095_club_creation_date_club_last_update_and_more'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='drawlog', |
||||
name='creation_date', |
||||
field=models.DateTimeField(default=django.utils.timezone.now, editable=False), |
||||
), |
||||
migrations.AddField( |
||||
model_name='drawlog', |
||||
name='last_update', |
||||
field=models.DateTimeField(default=django.utils.timezone.now), |
||||
), |
||||
migrations.AddField( |
||||
model_name='drawlog', |
||||
name='last_updated_by', |
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL), |
||||
), |
||||
migrations.AddField( |
||||
model_name='drawlog', |
||||
name='related_user', |
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL), |
||||
), |
||||
migrations.AddField( |
||||
model_name='drawlog', |
||||
name='store_id', |
||||
field=models.CharField(default='', max_length=100), |
||||
), |
||||
] |
||||
@ -1,30 +0,0 @@ |
||||
# Generated by Django 5.1 on 2024-12-13 13:04 |
||||
|
||||
from django.db import migrations |
||||
|
||||
def init_store_id(apps, schema_editor): |
||||
models = ["GroupStage", "Round", "TeamRegistration", "PlayerRegistration", "Match", "TeamScore", "DrawLog"] |
||||
for model in models: |
||||
Model = apps.get_model("tournaments", model) |
||||
for instance in Model.objects.all(): |
||||
instance.store_id = str(instance.tournament_id()) |
||||
instance.save() |
||||
|
||||
def init_related_names(apps, schema_editor): |
||||
models = ["Club", "Event"] |
||||
for model in models: |
||||
Model = apps.get_model("tournaments", model) |
||||
for instance in Model.objects.all(): |
||||
instance.related_user = instance.creator |
||||
instance.save() |
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('tournaments', '0095_club_creation_date_club_last_update_and_more'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.RunPython(init_store_id), |
||||
migrations.RunPython(init_related_names), |
||||
] |
||||
@ -0,0 +1,69 @@ |
||||
# Generated by Django 5.1 on 2024-12-13 13:04 |
||||
|
||||
from django.db import migrations |
||||
|
||||
def init_store_id(apps, schema_editor): |
||||
GroupStage = apps.get_model("tournaments", "GroupStage") |
||||
for instance in GroupStage.objects.all(): |
||||
instance.store_id = str(instance.tournament.id) |
||||
instance.save() |
||||
|
||||
Round = apps.get_model("tournaments", "Round") |
||||
for instance in Round.objects.all(): |
||||
instance.store_id = str(instance.tournament.id) |
||||
instance.save() |
||||
|
||||
TeamRegistration = apps.get_model("tournaments", "TeamRegistration") |
||||
for instance in TeamRegistration.objects.all(): |
||||
instance.store_id = str(instance.tournament.id) |
||||
instance.save() |
||||
|
||||
PlayerRegistration = apps.get_model("tournaments", "PlayerRegistration") |
||||
for instance in PlayerRegistration.objects.all(): |
||||
instance.store_id = str(instance.team_registration.tournament.id) |
||||
instance.save() |
||||
|
||||
Match = apps.get_model("tournaments", "Match") |
||||
for instance in Match.objects.all(): |
||||
if instance.round: |
||||
id = instance.round.tournament.id |
||||
else: |
||||
id = instance.group_stage.tournament.id |
||||
instance.store_id = str(id) |
||||
instance.save() |
||||
|
||||
TeamScore = apps.get_model("tournaments", "TeamScore") |
||||
for instance in TeamScore.objects.all(): |
||||
if instance.team_registration: |
||||
id = instance.team_registration.tournament.id |
||||
else: |
||||
if instance.match.round: |
||||
id = instance.round.tournament.id |
||||
else: |
||||
id = instance.group_stage.tournament.id |
||||
instance.store_id = str(id) |
||||
instance.save() |
||||
|
||||
DrawLog = apps.get_model("tournaments", "DrawLog") |
||||
for instance in DrawLog.objects.all(): |
||||
instance.store_id = str(instance.tournament.id) |
||||
instance.save() |
||||
|
||||
def init_related_names(apps, schema_editor): |
||||
models = ["Club", "Event"] |
||||
for model in models: |
||||
Model = apps.get_model("tournaments", model) |
||||
for instance in Model.objects.all(): |
||||
instance.related_user = instance.creator |
||||
instance.save() |
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('tournaments', '0096_drawlog_creation_date_drawlog_last_update_and_more'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.RunPython(init_store_id), |
||||
migrations.RunPython(init_related_names), |
||||
] |
||||
Loading…
Reference in new issue