From 632ca2bd9abd190a4f9f5ee8cdee9e3ef311a3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Tue, 16 Jun 2015 18:12:59 +0200 Subject: [PATCH] Renamed config variables. Fixed error in settings. --- openslides/assignments/models.py | 8 +- openslides/assignments/signals.py | 40 ++++----- openslides/assignments/views.py | 8 +- openslides/core/signals.py | 79 +++++++++-------- openslides/core/static/templates/index.html | 2 +- openslides/global_settings.py | 1 - openslides/motions/models.py | 16 ++-- openslides/motions/pdf.py | 14 ++-- openslides/motions/serializers.py | 2 +- openslides/motions/signals.py | 84 ++++++++++--------- openslides/motions/views.py | 6 +- openslides/users/auth.py | 13 ++- openslides/utils/pdf.py | 8 +- tests/integration/motions/test_views.py | 2 +- tests/integration/motions/test_viewset.py | 10 +-- .../users/test_rest_anonymous_user.py | 4 +- tests/old/motions/test_models.py | 10 +-- tests/old/utils/test_main.py | 4 +- tests/unit/users/test_auth.py | 9 +- 19 files changed, 164 insertions(+), 156 deletions(-) diff --git a/openslides/assignments/models.py b/openslides/assignments/models.py index 75d29ecb6..f41113a58 100644 --- a/openslides/assignments/models.py +++ b/openslides/assignments/models.py @@ -241,12 +241,12 @@ class Assignment(RESTModelMixin, SlideMixin, models.Model): candidates = self.candidates.all() # Find out the method of the election - if config['assignment_poll_vote_values'] == 'votes': + if config['assignments_poll_vote_values'] == 'votes': yesnoabstain = False - elif config['assignment_poll_vote_values'] == 'yesnoabstain': + elif config['assignments_poll_vote_values'] == 'yesnoabstain': yesnoabstain = True else: - # config['assignment_poll_vote_values'] == 'auto' + # config['assignments_poll_vote_values'] == 'auto' # candidates <= available posts -> yes/no/abstain if len(candidates) <= (self.open_posts - self.elected.count()): yesnoabstain = True @@ -366,7 +366,7 @@ class AssignmentPoll(RESTModelMixin, SlideMixin, CollectDefaultVotesMixin, return self.assignment.polls.filter(id__lte=self.pk).count() def get_percent_base_choice(self): - return config['assignment_poll_100_percent_base'] + return config['assignments_poll_100_percent_base'] def append_pollform_fields(self, fields): fields.append('description') diff --git a/openslides/assignments/signals.py b/openslides/assignments/signals.py index 7fbbb0b9a..71d5973ad 100644 --- a/openslides/assignments/signals.py +++ b/openslides/assignments/signals.py @@ -17,8 +17,8 @@ def setup_assignment_config(sender, **kwargs): app loading. """ # Ballot and ballot papers - assignment_poll_vote_values = ConfigVariable( - name='assignment_poll_vote_values', + assignments_poll_vote_values = ConfigVariable( + name='assignments_poll_vote_values', default_value='auto', form_field=forms.ChoiceField( widget=forms.Select(), @@ -28,16 +28,16 @@ def setup_assignment_config(sender, **kwargs): ('auto', ugettext_lazy('Automatic assign of method')), ('votes', ugettext_lazy('Always one option per candidate')), ('yesnoabstain', ugettext_lazy('Always Yes-No-Abstain per candidate'))))) - assignment_poll_100_percent_base = ConfigVariable( - name='assignment_poll_100_percent_base', + assignments_poll_100_percent_base = ConfigVariable( + name='assignments_poll_100_percent_base', default_value='WITHOUT_INVALID', form_field=forms.ChoiceField( widget=forms.Select(), required=False, label=ugettext_lazy('The 100 % base of an election result consists of'), choices=PERCENT_BASE_CHOICES)) - assignment_pdf_ballot_papers_selection = ConfigVariable( - name='assignment_pdf_ballot_papers_selection', + assignments_pdf_ballot_papers_selection = ConfigVariable( + name='assignments_pdf_ballot_papers_selection', default_value='CUSTOM_NUMBER', form_field=forms.ChoiceField( widget=forms.Select(), @@ -47,16 +47,16 @@ def setup_assignment_config(sender, **kwargs): ('NUMBER_OF_DELEGATES', ugettext_lazy('Number of all delegates')), ('NUMBER_OF_ALL_PARTICIPANTS', ugettext_lazy('Number of all participants')), ('CUSTOM_NUMBER', ugettext_lazy('Use the following custom number'))))) - assignment_pdf_ballot_papers_number = ConfigVariable( - name='assignment_pdf_ballot_papers_number', + assignments_pdf_ballot_papers_number = ConfigVariable( + name='assignments_pdf_ballot_papers_number', default_value=8, form_field=forms.IntegerField( widget=forms.TextInput(attrs={'class': 'small-input'}), required=False, min_value=1, label=ugettext_lazy('Custom number of ballot papers'))) - assignment_publish_winner_results_only = ConfigVariable( - name='assignment_publish_winner_results_only', + assignments_publish_winner_results_only = ConfigVariable( + name='assignments_publish_winner_results_only', default_value=False, form_field=forms.BooleanField( required=False, @@ -64,23 +64,23 @@ def setup_assignment_config(sender, **kwargs): '(projector view)'))) group_ballot = ConfigGroup( title=ugettext_lazy('Ballot and ballot papers'), - variables=(assignment_poll_vote_values, - assignment_poll_100_percent_base, - assignment_pdf_ballot_papers_selection, - assignment_pdf_ballot_papers_number, - assignment_publish_winner_results_only)) + variables=(assignments_poll_vote_values, + assignments_poll_100_percent_base, + assignments_pdf_ballot_papers_selection, + assignments_pdf_ballot_papers_number, + assignments_publish_winner_results_only)) # PDF - assignment_pdf_title = ConfigVariable( - name='assignment_pdf_title', + assignments_pdf_title = ConfigVariable( + name='assignments_pdf_title', default_value=_('Elections'), translatable=True, form_field=forms.CharField( widget=forms.TextInput(), required=False, label=ugettext_lazy('Title for PDF document (all elections)'))) - assignment_pdf_preamble = ConfigVariable( - name='assignment_pdf_preamble', + assignments_pdf_preamble = ConfigVariable( + name='assignments_pdf_preamble', default_value='', form_field=forms.CharField( widget=forms.Textarea(), @@ -88,7 +88,7 @@ def setup_assignment_config(sender, **kwargs): label=ugettext_lazy('Preamble text for PDF document (all elections)'))) group_pdf = ConfigGroup( title=ugettext_lazy('PDF'), - variables=(assignment_pdf_title, assignment_pdf_preamble)) + variables=(assignments_pdf_title, assignments_pdf_preamble)) return ConfigGroupedCollection( title=ugettext_noop('Elections'), diff --git a/openslides/assignments/views.py b/openslides/assignments/views.py index 433679c7b..f249df58e 100644 --- a/openslides/assignments/views.py +++ b/openslides/assignments/views.py @@ -252,9 +252,9 @@ class AssignmentPDF(PDFView): assignment_pk = None if assignment_pk is None: # print all assignments - title = escape(config["assignment_pdf_title"]) + title = escape(config["assignments_pdf_title"]) story.append(Paragraph(title, stylesheet['Heading1'])) - preamble = escape(config["assignment_pdf_preamble"]) + preamble = escape(config["assignments_pdf_preamble"]) if preamble: story.append(Paragraph( "%s" % preamble.replace('\r\n', '
'), @@ -468,8 +468,8 @@ class AssignmentPollPDF(PDFView): data = [] # get ballot papers config values - ballot_papers_selection = config["assignment_pdf_ballot_papers_selection"] - ballot_papers_number = config["assignment_pdf_ballot_papers_number"] + ballot_papers_selection = config["assignments_pdf_ballot_papers_selection"] + ballot_papers_number = config["assignments_pdf_ballot_papers_number"] # set number of ballot papers if ballot_papers_selection == "NUMBER_OF_DELEGATES": diff --git a/openslides/core/signals.py b/openslides/core/signals.py index 877e87b9c..e073839dc 100644 --- a/openslides/core/signals.py +++ b/openslides/core/signals.py @@ -18,20 +18,20 @@ post_permission_creation = Signal() def setup_general_config(sender, **kwargs): """ Receiver function to setup general config variables for OpenSlides. - They are grouped in 'Event', 'Welcome Widget' and 'System'. The - function is connected to the signal - openslides.config.signals.config_signal during app loading. + They are grouped in 'Event', 'Projector' and 'System'. This function is + connected to the signal openslides.config.signals.config_signal during + app loading. """ - event_name = ConfigVariable( - name='event_name', + general_event_name = ConfigVariable( + name='general_event_name', default_value='OpenSlides', form_field=forms.CharField( widget=forms.TextInput(), label=ugettext_lazy('Event name'), max_length=50)) - event_description = ConfigVariable( - name='event_description', + general_event_description = ConfigVariable( + name='general_event_description', default_value=_('Presentation and assembly system'), translatable=True, form_field=forms.CharField( @@ -40,30 +40,38 @@ def setup_general_config(sender, **kwargs): required=False, max_length=100)) - event_date = ConfigVariable( - name='event_date', + general_event_date = ConfigVariable( + name='general_event_date', default_value='', form_field=forms.CharField( widget=forms.TextInput(), label=ugettext_lazy('Event date'), required=False)) - event_location = ConfigVariable( - name='event_location', + general_event_location = ConfigVariable( + name='general_event_location', default_value='', form_field=forms.CharField( widget=forms.TextInput(), label=ugettext_lazy('Event location'), required=False)) - event_organizer = ConfigVariable( - name='event_organizer', + # TODO: Check whether this variable is ever used. + general_event_organizer = ConfigVariable( + name='general_event_organizer', default_value='', form_field=forms.CharField( widget=forms.TextInput(), label=ugettext_lazy('Event organizer'), required=False)) + general_system_enable_anonymous = ConfigVariable( + name='general_system_enable_anonymous', + default_value=False, + form_field=forms.BooleanField( + label=ugettext_lazy('Allow access for anonymous guest users'), + required=False)) + projector_enable_logo = ConfigVariable( name='projector_enable_logo', default_value=True, @@ -106,8 +114,8 @@ def setup_general_config(sender, **kwargs): help_text=ugettext_lazy('Use web color names like "red" or hex numbers like "#ff0000".'), required=True)) - welcome_title = ConfigVariable( - name='welcome_title', + projector_welcome_title = ConfigVariable( + name='projector_welcome_title', default_value=_('Welcome to OpenSlides'), translatable=True, form_field=forms.CharField( @@ -116,8 +124,8 @@ def setup_general_config(sender, **kwargs): help_text=ugettext_lazy('Also used for the default welcome slide.'), required=False)) - welcome_text = ConfigVariable( - name='welcome_text', + projector_welcome_text = ConfigVariable( + name='projector_welcome_text', default_value=_('[Place for your welcome text.]'), translatable=True, form_field=forms.CharField( @@ -125,31 +133,32 @@ def setup_general_config(sender, **kwargs): label=ugettext_lazy('Welcome text'), required=False)) - system_enable_anonymous = ConfigVariable( - name='system_enable_anonymous', - default_value=False, - form_field=forms.BooleanField( - label=ugettext_lazy('Allow access for anonymous guest users'), - required=False)) - group_event = ConfigGroup( title=ugettext_lazy('Event'), - variables=(event_name, event_description, event_date, event_location, event_organizer)) - - group_projector = ConfigGroup( - title=ugettext_lazy('Projector'), - variables=(projector_enable_logo, projector_enable_title, projector_backgroundcolor1, projector_backgroundcolor2, projector_fontcolor)) - - group_welcome_widget = ConfigGroup( - title=ugettext_lazy('Welcome Widget'), - variables=(welcome_title, welcome_text)) + variables=( + general_event_name, + general_event_description, + general_event_date, + general_event_location, + general_event_organizer)) group_system = ConfigGroup( title=ugettext_lazy('System'), - variables=(system_enable_anonymous,)) + variables=(general_system_enable_anonymous,)) + + group_projector = ConfigGroup( + title=ugettext_lazy('Projector'), + variables=( + projector_enable_logo, + projector_enable_title, + projector_backgroundcolor1, + projector_backgroundcolor2, + projector_fontcolor, + projector_welcome_title, + projector_welcome_text)) return ConfigGroupedCollection( title=ugettext_noop('General'), url='general', weight=10, - groups=(group_event, group_projector, group_welcome_widget, group_system)) + groups=(group_event, group_system, group_projector)) diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html index c5431459e..b153f71bf 100644 --- a/openslides/core/static/templates/index.html +++ b/openslides/core/static/templates/index.html @@ -20,7 +20,7 @@ - {{ config('event_name') }} + {{ config('general_event_name') }}