Merge pull request #5910 from mdickopp/mdickopp/list-of-speakers-inital-state-configurable

Make configurable whether a newly created list of speakers is initial…
This commit is contained in:
Finn Stutzenstein 2021-03-11 08:56:29 +01:00 committed by GitHub
commit 520915c3f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 1 deletions

View File

@ -33,3 +33,4 @@ Authors of OpenSlides in chronological order of first contribution:
Joshua Sangmeister <joshua.sangmeister@gmail.com> Joshua Sangmeister <joshua.sangmeister@gmail.com>
Gernot Schulz <gernot@intevtion.de> Gernot Schulz <gernot@intevtion.de>
Raphael Topel <info@rtopel.de> Raphael Topel <info@rtopel.de>
Martin Dickopp <martin@zero-based.org>

View File

@ -125,6 +125,7 @@ _('Enable points of order');
_('[Begin speech] starts the countdown, [End speech] stops the countdown.'); _('[Begin speech] starts the countdown, [End speech] stops the countdown.');
_('Only present participants can be added to the list of speakers'); _('Only present participants can be added to the list of speakers');
_('Show hint »first speech« in the list of speakers management view'); _('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)'); _('Default visibility for new agenda items (except topics)');
_('public'); _('public');
_('internal'); _('internal');

View File

@ -210,3 +210,13 @@ def get_config_variables():
group="Agenda", group="Agenda",
subgroup="List of speakers", 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",
)

View File

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

View File

@ -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): class ListOfSpeakers(RESTModelMixin, models.Model):
access_permissions = ListOfSpeakersAccessPermissions() 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. 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. True, if the list of speakers is closed.
""" """

View File

@ -1,4 +1,5 @@
from openslides.agenda.models import Item from openslides.agenda.models import Item
from openslides.core.config import config
from openslides.topics.models import Topic from openslides.topics.models import Topic
from tests.test_case import TestCase from tests.test_case import TestCase
@ -13,3 +14,40 @@ class TestItemManager(TestCase):
with self.assertNumQueries(1): with self.assertNumQueries(1):
Item.objects.get_root_and_children() 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)