From 5dcea0cf290ba63e6fb1c8c7f45f958bbdf1d09f Mon Sep 17 00:00:00 2001 From: juuso-j <68938778+juuso-j@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:49:23 +0300 Subject: [PATCH] Situation can have multiple announcemounts --- ...02_alter_situationannouncement_location.py | 25 +++++++++++++++++++ exceptional_situations/models.py | 4 +-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 exceptional_situations/migrations/0002_alter_situationannouncement_location.py diff --git a/exceptional_situations/migrations/0002_alter_situationannouncement_location.py b/exceptional_situations/migrations/0002_alter_situationannouncement_location.py new file mode 100644 index 000000000..9e1925293 --- /dev/null +++ b/exceptional_situations/migrations/0002_alter_situationannouncement_location.py @@ -0,0 +1,25 @@ +# Generated by Django 4.1.13 on 2024-06-20 07:37 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("exceptional_situations", "0001_initial"), + ] + + operations = [ + migrations.AlterField( + model_name="situationannouncement", + name="location", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="announcements", + to="exceptional_situations.situationlocation", + ), + ), + ] diff --git a/exceptional_situations/models.py b/exceptional_situations/models.py index 7b138ec46..1ea08a353 100644 --- a/exceptional_situations/models.py +++ b/exceptional_situations/models.py @@ -32,12 +32,12 @@ class SituationAnnouncement(models.Model): start_time = models.DateTimeField() end_time = models.DateTimeField(null=True, blank=True) additional_info = models.JSONField(null=True, blank=True) - location = models.OneToOneField( + location = models.ForeignKey( SituationLocation, on_delete=models.CASCADE, null=True, blank=True, - related_name="announcement", + related_name="announcements", ) class Meta: