From 41a34473571c71d02fc8ae0e148851f71d5522e3 Mon Sep 17 00:00:00 2001 From: Finn Stutzenstein Date: Mon, 22 Mar 2021 08:51:29 +0100 Subject: [PATCH] Fix LOS initially closed migration issue --- .../0011_list_of_speakers_closed_default.py | 10 ++++---- .../0012_list_of_speakers_closed_default.py | 24 +++++++++++++++++++ server/openslides/agenda/models.py | 9 +------ server/openslides/agenda/signals.py | 5 +++- 4 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 server/openslides/agenda/migrations/0012_list_of_speakers_closed_default.py diff --git a/server/openslides/agenda/migrations/0011_list_of_speakers_closed_default.py b/server/openslides/agenda/migrations/0011_list_of_speakers_closed_default.py index 9bcd07d9d..22fbb5b6d 100644 --- a/server/openslides/agenda/migrations/0011_list_of_speakers_closed_default.py +++ b/server/openslides/agenda/migrations/0011_list_of_speakers_closed_default.py @@ -2,10 +2,12 @@ from django.db import migrations, models -import openslides.agenda.models - class Migration(migrations.Migration): + """ + The default formerly was openslides.agenda.models.list_of_speakers_initially_closed + This function does not exists anymore, so for new migrations, we replaced it with False. + """ dependencies = [ ("agenda", "0010_speaker_point_of_order"), @@ -15,8 +17,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="listofspeakers", name="closed", - field=models.BooleanField( - default=openslides.agenda.models.list_of_speakers_initially_closed - ), + field=models.BooleanField(default=False), ), ] diff --git a/server/openslides/agenda/migrations/0012_list_of_speakers_closed_default.py b/server/openslides/agenda/migrations/0012_list_of_speakers_closed_default.py new file mode 100644 index 000000000..c211a8a8e --- /dev/null +++ b/server/openslides/agenda/migrations/0012_list_of_speakers_closed_default.py @@ -0,0 +1,24 @@ +# Generated by Finn Stutzenstein on 2021-03-22 08:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + """ + Reverts the previous migration to replace + openslides.agenda.models.list_of_speakers_initially_closed + with False. If this is a new database and the previous migration was + not run before, this one has no effect. + """ + + dependencies = [ + ("agenda", "0011_list_of_speakers_closed_default"), + ] + + operations = [ + migrations.AlterField( + model_name="listofspeakers", + name="closed", + field=models.BooleanField(default=False), + ), + ] diff --git a/server/openslides/agenda/models.py b/server/openslides/agenda/models.py index a3b5085c8..cb81575e9 100644 --- a/server/openslides/agenda/models.py +++ b/server/openslides/agenda/models.py @@ -357,13 +357,6 @@ class ListOfSpeakersManager(BaseManager): ) -def list_of_speakers_initially_closed(): - """ - Return whether a newly created list of speakers is initially closed. - """ - return config["agenda_list_of_speakers_initially_closed"] - - class ListOfSpeakers(RESTModelMixin, models.Model): objects = ListOfSpeakersManager() @@ -386,7 +379,7 @@ class ListOfSpeakers(RESTModelMixin, models.Model): Field for generic relation to a related object. General field to the related object. """ - closed = models.BooleanField(default=list_of_speakers_initially_closed) + closed = models.BooleanField(default=False) """ True, if the list of speakers is closed. """ diff --git a/server/openslides/agenda/signals.py b/server/openslides/agenda/signals.py index 8e2fb38d0..03c7a0721 100644 --- a/server/openslides/agenda/signals.py +++ b/server/openslides/agenda/signals.py @@ -85,7 +85,10 @@ def listen_to_related_object_post_save(sender, instance, created, **kwargs): if is_list_of_speakers_content_object: if created: - ListOfSpeakers.objects.create(content_object=instance) + ListOfSpeakers.objects.create( + content_object=instance, + closed=config["agenda_list_of_speakers_initially_closed"], + ) if not instance.list_of_speakers_skip_autoupdate: instance_inform_changed_data = True