From a9d223121ec3c67f17f663ffdce67c318ec74292 Mon Sep 17 00:00:00 2001 From: Martin Dickopp Date: Sat, 20 Feb 2021 12:03:05 +0100 Subject: [PATCH] Make configurable whether a newly created list of speakers is initially open or closed --- AUTHORS | 1 + .../app/core/translate/marked-translations.ts | 1 + server/openslides/agenda/config_variables.py | 10 +++++ .../0011_list_of_speakers_closed_default.py | 22 +++++++++++ server/openslides/agenda/models.py | 9 ++++- .../tests/integration/agenda/test_models.py | 38 +++++++++++++++++++ 6 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 server/openslides/agenda/migrations/0011_list_of_speakers_closed_default.py diff --git a/AUTHORS b/AUTHORS index 45c659d04..099a77059 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,3 +33,4 @@ Authors of OpenSlides in chronological order of first contribution: Joshua Sangmeister Gernot Schulz Raphael Topel + Martin Dickopp diff --git a/client/src/app/core/translate/marked-translations.ts b/client/src/app/core/translate/marked-translations.ts index 3fc6702e8..25fea7849 100644 --- a/client/src/app/core/translate/marked-translations.ts +++ b/client/src/app/core/translate/marked-translations.ts @@ -125,6 +125,7 @@ _('Enable points of order'); _('[Begin speech] starts the countdown, [End speech] stops the countdown.'); _('Only present participants can be added to the list of speakers'); _('Show hint »first speech« in the list of speakers management view'); +_('List of speakers is initially closed'); _('Default visibility for new agenda items (except topics)'); _('public'); _('internal'); diff --git a/server/openslides/agenda/config_variables.py b/server/openslides/agenda/config_variables.py index 340efb47d..a62d99434 100644 --- a/server/openslides/agenda/config_variables.py +++ b/server/openslides/agenda/config_variables.py @@ -210,3 +210,13 @@ def get_config_variables(): group="Agenda", subgroup="List of speakers", ) + + yield ConfigVariable( + name="agenda_list_of_speakers_initially_closed", + default_value=False, + input_type="boolean", + label="List of speakers is initially closed", + weight=235, + group="Agenda", + subgroup="List of speakers", + ) 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 new file mode 100644 index 000000000..9bcd07d9d --- /dev/null +++ b/server/openslides/agenda/migrations/0011_list_of_speakers_closed_default.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.19 on 2021-03-08 14:40 + +from django.db import migrations, models + +import openslides.agenda.models + + +class Migration(migrations.Migration): + + dependencies = [ + ("agenda", "0010_speaker_point_of_order"), + ] + + operations = [ + migrations.AlterField( + model_name="listofspeakers", + name="closed", + field=models.BooleanField( + default=openslides.agenda.models.list_of_speakers_initially_closed + ), + ), + ] diff --git a/server/openslides/agenda/models.py b/server/openslides/agenda/models.py index d78c521b4..f84423032 100644 --- a/server/openslides/agenda/models.py +++ b/server/openslides/agenda/models.py @@ -360,6 +360,13 @@ 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): access_permissions = ListOfSpeakersAccessPermissions() @@ -383,7 +390,7 @@ class ListOfSpeakers(RESTModelMixin, models.Model): Field for generic relation to a related object. General field to the related object. """ - closed = models.BooleanField(default=False) + closed = models.BooleanField(default=list_of_speakers_initially_closed) """ True, if the list of speakers is closed. """ diff --git a/server/tests/integration/agenda/test_models.py b/server/tests/integration/agenda/test_models.py index 0f5356a0d..c627740d7 100644 --- a/server/tests/integration/agenda/test_models.py +++ b/server/tests/integration/agenda/test_models.py @@ -1,4 +1,5 @@ from openslides.agenda.models import Item +from openslides.core.config import config from openslides.topics.models import Topic from tests.test_case import TestCase @@ -13,3 +14,40 @@ class TestItemManager(TestCase): with self.assertNumQueries(1): Item.objects.get_root_and_children() + + +class TestListOfSpeakers(TestCase): + def test_open_if_initial_state_configured_to_be_open(self): + """ + Test a newly created list of speakers is open if the + agenda_list_of_speakers_initially_closed configuration variable has + been set to False. + """ + config["agenda_list_of_speakers_initially_closed"] = False + list_of_speakers = Topic.objects.create( + title="list_of_speakers" + ).list_of_speakers + self.assertFalse(list_of_speakers.closed) + + def test_closed_if_initial_state_configured_to_be_closed(self): + """ + Test a newly created list of speakers is closed if the + agenda_list_of_speakers_initially_closed configuration variable has + been set to True. + """ + config["agenda_list_of_speakers_initially_closed"] = True + list_of_speakers = Topic.objects.create( + title="list_of_speakers" + ).list_of_speakers + self.assertTrue(list_of_speakers.closed) + + def test_open_if_initial_state_not_configured(self): + """ + Test a newly created list of speakers is open if the + agenda_list_of_speakers_initially_closed configuration variable has + not been set. + """ + list_of_speakers = Topic.objects.create( + title="list_of_speakers" + ).list_of_speakers + self.assertFalse(list_of_speakers.closed)