Fix LOS initially closed migration issue

This commit is contained in:
Finn Stutzenstein 2021-03-22 08:51:29 +01:00
parent 7bbd8688a2
commit 41a3447357
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
4 changed files with 34 additions and 14 deletions

View File

@ -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),
),
]

View File

@ -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),
),
]

View File

@ -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.
"""

View File

@ -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