Skip to content

Commit

Permalink
Add temp measures to get prod deployed.
Browse files Browse the repository at this point in the history
  • Loading branch information
lladdy committed Jun 13, 2022
1 parent 69efb63 commit 745cada
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
16 changes: 0 additions & 16 deletions aiarena/core/migrations/0047_auto_20220523_0307.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,8 @@
from django.db import migrations, models
import django.db.models.deletion

from aiarena.core.models import Bot
from aiarena.core.models.bot_race import BotRace


def link_bot_races(apps, schema_editor):
if Bot.objects.count() > 0:
BotRace.create_all_races()

BotModel = apps.get_model('core', 'Bot')

for bot in BotModel.objects.all():
br = BotRace.objects.filter(label=bot.plays_race_model).first()
bot.plays_race_model = br
bot.save()

class Migration(migrations.Migration):

dependencies = [
('core', '0046_competitionbotmapstats'),
]
Expand All @@ -37,5 +22,4 @@ class Migration(migrations.Migration):
name='plays_race_model',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='core.botrace'),
),
migrations.RunPython(link_bot_races),
]
21 changes: 16 additions & 5 deletions aiarena/core/migrations/0048_auto_20220523_0329.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,27 @@

from django.db import migrations

from aiarena.core.models import Bot
from aiarena.core.models.bot_race import BotRace

class Migration(migrations.Migration):

def link_bot_races(apps, schema_editor):
if Bot.objects.count() > 0:
BotRace.create_all_races()

for bot in Bot.objects.all():
br = BotRace.objects.get(label=bot.plays_race)
bot.plays_race_model_id = br.id
bot.save()

assert Bot.objects.filter(plays_race_model=None).count() == 0


class Migration(migrations.Migration):
dependencies = [
('core', '0047_auto_20220523_0307'),
]

operations = [
migrations.RemoveField(
model_name='bot',
name='plays_race',
),
migrations.RunPython(link_bot_races),
]
10 changes: 5 additions & 5 deletions aiarena/core/migrations/0049_alter_bot_plays_race_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class Migration(migrations.Migration):
]

operations = [
migrations.AlterField(
model_name='bot',
name='plays_race_model',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.botrace'),
),
# migrations.AlterField(
# model_name='bot',
# name='plays_race_model',
# field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.botrace'),
# ),
]
9 changes: 8 additions & 1 deletion aiarena/core/models/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ def bot_data_upload_to(instance, filename):


class Bot(models.Model, LockableModelMixin):
RACES = (
('T', 'Terran'),
('Z', 'Zerg'),
('P', 'Protoss'),
('R', 'Random'),
)
TYPES = ( # todo: update display names. capitalize etc
('cppwin32', 'cppwin32'),
('cpplinux', 'cpplinux'),
Expand Down Expand Up @@ -69,8 +75,9 @@ class Bot(models.Model, LockableModelMixin):
blank=True, null=True)
bot_data_md5hash = models.CharField(max_length=32, editable=False, null=True)
bot_data_publicly_downloadable = models.BooleanField(default=False)
plays_race = models.CharField(max_length=1, choices=RACES)
# todo: rename back to plays_race
plays_race_model = models.ForeignKey(BotRace, on_delete=models.PROTECT)
plays_race_model = models.ForeignKey(BotRace, on_delete=models.PROTECT, null=True)
type = models.CharField(max_length=32, choices=TYPES)
# the ID displayed to other bots during a game so they can recognize their opponent
game_display_id = models.UUIDField(default=uuid.uuid4)
Expand Down

0 comments on commit 745cada

Please sign in to comment.