From 96ecd479e772dedc6487d081c98cf89ba45f9b60 Mon Sep 17 00:00:00 2001 From: johnpooch Date: Mon, 10 May 2021 16:24:11 +0100 Subject: [PATCH] Convert Piece.dislodged_from to ForeignKey One to one is incorrect for this relationship and was causing adjudication to fail --- .../0010_alter_piecestate_dislodged_from.py | 19 +++++++++++++++++++ core/models/piece.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 core/migrations/0010_alter_piecestate_dislodged_from.py diff --git a/core/migrations/0010_alter_piecestate_dislodged_from.py b/core/migrations/0010_alter_piecestate_dislodged_from.py new file mode 100644 index 0000000..dcef872 --- /dev/null +++ b/core/migrations/0010_alter_piecestate_dislodged_from.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2 on 2021-05-10 15:23 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0009_piece_turn_destroyed'), + ] + + operations = [ + migrations.AlterField( + model_name='piecestate', + name='dislodged_from', + field=models.ForeignKey(blank=True, help_text="True if the piece was dislodged via a land attack during this turn. The piece's attacker_territory field will be set to this value next turn.", null=True, on_delete=django.db.models.deletion.CASCADE, related_name='pieces_dislodged_from_here', to='core.territory'), + ), + ] diff --git a/core/models/piece.py b/core/models/piece.py index f4e1ea3..c88b143 100644 --- a/core/models/piece.py +++ b/core/models/piece.py @@ -110,7 +110,7 @@ class PieceState(PerTurnModel): on_delete=models.CASCADE, related_name='piece_dislodged', ) - dislodged_from = models.OneToOneField( + dislodged_from = models.ForeignKey( 'Territory', blank=True, null=True,