Renamed config variables. Fixed error in settings.

This commit is contained in:
Norman Jäckel 2015-06-16 18:12:59 +02:00
parent b703655153
commit 632ca2bd9a
19 changed files with 164 additions and 156 deletions

View File

@ -241,12 +241,12 @@ class Assignment(RESTModelMixin, SlideMixin, models.Model):
candidates = self.candidates.all() candidates = self.candidates.all()
# Find out the method of the election # Find out the method of the election
if config['assignment_poll_vote_values'] == 'votes': if config['assignments_poll_vote_values'] == 'votes':
yesnoabstain = False yesnoabstain = False
elif config['assignment_poll_vote_values'] == 'yesnoabstain': elif config['assignments_poll_vote_values'] == 'yesnoabstain':
yesnoabstain = True yesnoabstain = True
else: else:
# config['assignment_poll_vote_values'] == 'auto' # config['assignments_poll_vote_values'] == 'auto'
# candidates <= available posts -> yes/no/abstain # candidates <= available posts -> yes/no/abstain
if len(candidates) <= (self.open_posts - self.elected.count()): if len(candidates) <= (self.open_posts - self.elected.count()):
yesnoabstain = True yesnoabstain = True
@ -366,7 +366,7 @@ class AssignmentPoll(RESTModelMixin, SlideMixin, CollectDefaultVotesMixin,
return self.assignment.polls.filter(id__lte=self.pk).count() return self.assignment.polls.filter(id__lte=self.pk).count()
def get_percent_base_choice(self): 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): def append_pollform_fields(self, fields):
fields.append('description') fields.append('description')

View File

@ -17,8 +17,8 @@ def setup_assignment_config(sender, **kwargs):
app loading. app loading.
""" """
# Ballot and ballot papers # Ballot and ballot papers
assignment_poll_vote_values = ConfigVariable( assignments_poll_vote_values = ConfigVariable(
name='assignment_poll_vote_values', name='assignments_poll_vote_values',
default_value='auto', default_value='auto',
form_field=forms.ChoiceField( form_field=forms.ChoiceField(
widget=forms.Select(), widget=forms.Select(),
@ -28,16 +28,16 @@ def setup_assignment_config(sender, **kwargs):
('auto', ugettext_lazy('Automatic assign of method')), ('auto', ugettext_lazy('Automatic assign of method')),
('votes', ugettext_lazy('Always one option per candidate')), ('votes', ugettext_lazy('Always one option per candidate')),
('yesnoabstain', ugettext_lazy('Always Yes-No-Abstain per candidate'))))) ('yesnoabstain', ugettext_lazy('Always Yes-No-Abstain per candidate')))))
assignment_poll_100_percent_base = ConfigVariable( assignments_poll_100_percent_base = ConfigVariable(
name='assignment_poll_100_percent_base', name='assignments_poll_100_percent_base',
default_value='WITHOUT_INVALID', default_value='WITHOUT_INVALID',
form_field=forms.ChoiceField( form_field=forms.ChoiceField(
widget=forms.Select(), widget=forms.Select(),
required=False, required=False,
label=ugettext_lazy('The 100 % base of an election result consists of'), label=ugettext_lazy('The 100 % base of an election result consists of'),
choices=PERCENT_BASE_CHOICES)) choices=PERCENT_BASE_CHOICES))
assignment_pdf_ballot_papers_selection = ConfigVariable( assignments_pdf_ballot_papers_selection = ConfigVariable(
name='assignment_pdf_ballot_papers_selection', name='assignments_pdf_ballot_papers_selection',
default_value='CUSTOM_NUMBER', default_value='CUSTOM_NUMBER',
form_field=forms.ChoiceField( form_field=forms.ChoiceField(
widget=forms.Select(), widget=forms.Select(),
@ -47,16 +47,16 @@ def setup_assignment_config(sender, **kwargs):
('NUMBER_OF_DELEGATES', ugettext_lazy('Number of all delegates')), ('NUMBER_OF_DELEGATES', ugettext_lazy('Number of all delegates')),
('NUMBER_OF_ALL_PARTICIPANTS', ugettext_lazy('Number of all participants')), ('NUMBER_OF_ALL_PARTICIPANTS', ugettext_lazy('Number of all participants')),
('CUSTOM_NUMBER', ugettext_lazy('Use the following custom number'))))) ('CUSTOM_NUMBER', ugettext_lazy('Use the following custom number')))))
assignment_pdf_ballot_papers_number = ConfigVariable( assignments_pdf_ballot_papers_number = ConfigVariable(
name='assignment_pdf_ballot_papers_number', name='assignments_pdf_ballot_papers_number',
default_value=8, default_value=8,
form_field=forms.IntegerField( form_field=forms.IntegerField(
widget=forms.TextInput(attrs={'class': 'small-input'}), widget=forms.TextInput(attrs={'class': 'small-input'}),
required=False, required=False,
min_value=1, min_value=1,
label=ugettext_lazy('Custom number of ballot papers'))) label=ugettext_lazy('Custom number of ballot papers')))
assignment_publish_winner_results_only = ConfigVariable( assignments_publish_winner_results_only = ConfigVariable(
name='assignment_publish_winner_results_only', name='assignments_publish_winner_results_only',
default_value=False, default_value=False,
form_field=forms.BooleanField( form_field=forms.BooleanField(
required=False, required=False,
@ -64,23 +64,23 @@ def setup_assignment_config(sender, **kwargs):
'(projector view)'))) '(projector view)')))
group_ballot = ConfigGroup( group_ballot = ConfigGroup(
title=ugettext_lazy('Ballot and ballot papers'), title=ugettext_lazy('Ballot and ballot papers'),
variables=(assignment_poll_vote_values, variables=(assignments_poll_vote_values,
assignment_poll_100_percent_base, assignments_poll_100_percent_base,
assignment_pdf_ballot_papers_selection, assignments_pdf_ballot_papers_selection,
assignment_pdf_ballot_papers_number, assignments_pdf_ballot_papers_number,
assignment_publish_winner_results_only)) assignments_publish_winner_results_only))
# PDF # PDF
assignment_pdf_title = ConfigVariable( assignments_pdf_title = ConfigVariable(
name='assignment_pdf_title', name='assignments_pdf_title',
default_value=_('Elections'), default_value=_('Elections'),
translatable=True, translatable=True,
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.TextInput(), widget=forms.TextInput(),
required=False, required=False,
label=ugettext_lazy('Title for PDF document (all elections)'))) label=ugettext_lazy('Title for PDF document (all elections)')))
assignment_pdf_preamble = ConfigVariable( assignments_pdf_preamble = ConfigVariable(
name='assignment_pdf_preamble', name='assignments_pdf_preamble',
default_value='', default_value='',
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.Textarea(), widget=forms.Textarea(),
@ -88,7 +88,7 @@ def setup_assignment_config(sender, **kwargs):
label=ugettext_lazy('Preamble text for PDF document (all elections)'))) label=ugettext_lazy('Preamble text for PDF document (all elections)')))
group_pdf = ConfigGroup( group_pdf = ConfigGroup(
title=ugettext_lazy('PDF'), title=ugettext_lazy('PDF'),
variables=(assignment_pdf_title, assignment_pdf_preamble)) variables=(assignments_pdf_title, assignments_pdf_preamble))
return ConfigGroupedCollection( return ConfigGroupedCollection(
title=ugettext_noop('Elections'), title=ugettext_noop('Elections'),

View File

@ -252,9 +252,9 @@ class AssignmentPDF(PDFView):
assignment_pk = None assignment_pk = None
if assignment_pk is None: # print all assignments 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'])) story.append(Paragraph(title, stylesheet['Heading1']))
preamble = escape(config["assignment_pdf_preamble"]) preamble = escape(config["assignments_pdf_preamble"])
if preamble: if preamble:
story.append(Paragraph( story.append(Paragraph(
"%s" % preamble.replace('\r\n', '<br/>'), "%s" % preamble.replace('\r\n', '<br/>'),
@ -468,8 +468,8 @@ class AssignmentPollPDF(PDFView):
data = [] data = []
# get ballot papers config values # get ballot papers config values
ballot_papers_selection = config["assignment_pdf_ballot_papers_selection"] ballot_papers_selection = config["assignments_pdf_ballot_papers_selection"]
ballot_papers_number = config["assignment_pdf_ballot_papers_number"] ballot_papers_number = config["assignments_pdf_ballot_papers_number"]
# set number of ballot papers # set number of ballot papers
if ballot_papers_selection == "NUMBER_OF_DELEGATES": if ballot_papers_selection == "NUMBER_OF_DELEGATES":

View File

@ -18,20 +18,20 @@ post_permission_creation = Signal()
def setup_general_config(sender, **kwargs): def setup_general_config(sender, **kwargs):
""" """
Receiver function to setup general config variables for OpenSlides. Receiver function to setup general config variables for OpenSlides.
They are grouped in 'Event', 'Welcome Widget' and 'System'. The They are grouped in 'Event', 'Projector' and 'System'. This function is
function is connected to the signal connected to the signal openslides.config.signals.config_signal during
openslides.config.signals.config_signal during app loading. app loading.
""" """
event_name = ConfigVariable( general_event_name = ConfigVariable(
name='event_name', name='general_event_name',
default_value='OpenSlides', default_value='OpenSlides',
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.TextInput(), widget=forms.TextInput(),
label=ugettext_lazy('Event name'), label=ugettext_lazy('Event name'),
max_length=50)) max_length=50))
event_description = ConfigVariable( general_event_description = ConfigVariable(
name='event_description', name='general_event_description',
default_value=_('Presentation and assembly system'), default_value=_('Presentation and assembly system'),
translatable=True, translatable=True,
form_field=forms.CharField( form_field=forms.CharField(
@ -40,30 +40,38 @@ def setup_general_config(sender, **kwargs):
required=False, required=False,
max_length=100)) max_length=100))
event_date = ConfigVariable( general_event_date = ConfigVariable(
name='event_date', name='general_event_date',
default_value='', default_value='',
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.TextInput(), widget=forms.TextInput(),
label=ugettext_lazy('Event date'), label=ugettext_lazy('Event date'),
required=False)) required=False))
event_location = ConfigVariable( general_event_location = ConfigVariable(
name='event_location', name='general_event_location',
default_value='', default_value='',
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.TextInput(), widget=forms.TextInput(),
label=ugettext_lazy('Event location'), label=ugettext_lazy('Event location'),
required=False)) required=False))
event_organizer = ConfigVariable( # TODO: Check whether this variable is ever used.
name='event_organizer', general_event_organizer = ConfigVariable(
name='general_event_organizer',
default_value='', default_value='',
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.TextInput(), widget=forms.TextInput(),
label=ugettext_lazy('Event organizer'), label=ugettext_lazy('Event organizer'),
required=False)) 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( projector_enable_logo = ConfigVariable(
name='projector_enable_logo', name='projector_enable_logo',
default_value=True, 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".'), help_text=ugettext_lazy('Use web color names like "red" or hex numbers like "#ff0000".'),
required=True)) required=True))
welcome_title = ConfigVariable( projector_welcome_title = ConfigVariable(
name='welcome_title', name='projector_welcome_title',
default_value=_('Welcome to OpenSlides'), default_value=_('Welcome to OpenSlides'),
translatable=True, translatable=True,
form_field=forms.CharField( 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.'), help_text=ugettext_lazy('Also used for the default welcome slide.'),
required=False)) required=False))
welcome_text = ConfigVariable( projector_welcome_text = ConfigVariable(
name='welcome_text', name='projector_welcome_text',
default_value=_('[Place for your welcome text.]'), default_value=_('[Place for your welcome text.]'),
translatable=True, translatable=True,
form_field=forms.CharField( form_field=forms.CharField(
@ -125,31 +133,32 @@ def setup_general_config(sender, **kwargs):
label=ugettext_lazy('Welcome text'), label=ugettext_lazy('Welcome text'),
required=False)) 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( group_event = ConfigGroup(
title=ugettext_lazy('Event'), title=ugettext_lazy('Event'),
variables=(event_name, event_description, event_date, event_location, event_organizer)) variables=(
general_event_name,
group_projector = ConfigGroup( general_event_description,
title=ugettext_lazy('Projector'), general_event_date,
variables=(projector_enable_logo, projector_enable_title, projector_backgroundcolor1, projector_backgroundcolor2, projector_fontcolor)) general_event_location,
general_event_organizer))
group_welcome_widget = ConfigGroup(
title=ugettext_lazy('Welcome Widget'),
variables=(welcome_title, welcome_text))
group_system = ConfigGroup( group_system = ConfigGroup(
title=ugettext_lazy('System'), 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( return ConfigGroupedCollection(
title=ugettext_noop('General'), title=ugettext_noop('General'),
url='general', url='general',
weight=10, weight=10,
groups=(group_event, group_projector, group_welcome_widget, group_system)) groups=(group_event, group_system, group_projector))

View File

@ -20,7 +20,7 @@
<a ui-sref="dashboard" class="navbar-brand"> <a ui-sref="dashboard" class="navbar-brand">
<img id="logo" src="/static/img/logo.png" alt="OpenSlides" /> <img id="logo" src="/static/img/logo.png" alt="OpenSlides" />
</a> </a>
<span class="navbar-text optional">{{ config('event_name') }}</span> <span class="navbar-text optional">{{ config('general_event_name') }}</span>
</div> </div>
<div class="navbar-right" ng-controller="userMenu"> <div class="navbar-right" ng-controller="userMenu">
<!-- login/logout button --> <!-- login/logout button -->

View File

@ -100,7 +100,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request', 'django.core.context_processors.request',
'django.core.context_processors.i18n', 'django.core.context_processors.i18n',
'django.core.context_processors.static', 'django.core.context_processors.static',
'openslides.utils.main_menu.main_menu_entries',
'openslides.core.chatbox.chat_messages_context_processor', 'openslides.core.chatbox.chat_messages_context_processor',
) )

View File

@ -217,7 +217,7 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
it is not set yet. it is not set yet.
""" """
# The identifier is already set or should be set manually # The identifier is already set or should be set manually
if config['motion_identifier'] == 'manually' or self.identifier: if config['motions_identifier'] == 'manually' or self.identifier:
# Do not set an identifier. # Do not set an identifier.
return return
@ -226,7 +226,7 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
motions = self.parent.amendments.all() motions = self.parent.amendments.all()
# The motions should be counted per category # The motions should be counted per category
elif config['motion_identifier'] == 'per_category': elif config['motions_identifier'] == 'per_category':
motions = Motion.objects.filter(category=self.category) motions = Motion.objects.filter(category=self.category)
# The motions should be counted over all. # The motions should be counted over all.
@ -236,7 +236,7 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
number = motions.aggregate(Max('identifier_number'))['identifier_number__max'] or 0 number = motions.aggregate(Max('identifier_number'))['identifier_number__max'] or 0
if self.is_amendment(): if self.is_amendment():
parent_identifier = self.parent.identifier or '' parent_identifier = self.parent.identifier or ''
prefix = '%s %s ' % (parent_identifier, config['motion_amendments_prefix']) prefix = '%s %s ' % (parent_identifier, config['motions_amendments_prefix'])
elif self.category is None or not self.category.prefix: elif self.category is None or not self.category.prefix:
prefix = '' prefix = ''
else: else:
@ -440,8 +440,8 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
elif self.state: elif self.state:
new_state = self.state.workflow.first_state new_state = self.state.workflow.first_state
else: else:
new_state = (Workflow.objects.get(pk=config['motion_workflow']).first_state or new_state = (Workflow.objects.get(pk=config['motions_workflow']).first_state or
Workflow.objects.get(pk=config['motion_workflow']).state_set.all()[0]) Workflow.objects.get(pk=config['motions_workflow']).state_set.all()[0])
self.set_state(new_state) self.set_state(new_state)
def get_agenda_title(self): def get_agenda_title(self):
@ -488,7 +488,7 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
self.state.allow_create_poll), self.state.allow_create_poll),
'support': (self.state.allow_support and 'support': (self.state.allow_support and
config['motion_min_supporters'] > 0 and config['motions_min_supporters'] > 0 and
not self.is_submitter(person) and not self.is_submitter(person) and
not self.is_supporter(person)), not self.is_supporter(person)),
@ -519,7 +519,7 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
A motion is a amendment if amendments are activated in the config and A motion is a amendment if amendments are activated in the config and
the motion has a parent. the motion has a parent.
""" """
return config['motion_amendments_enabled'] and self.parent is not None return config['motions_amendments_enabled'] and self.parent is not None
class MotionVersion(RESTModelMixin, models.Model): class MotionVersion(RESTModelMixin, models.Model):
@ -697,7 +697,7 @@ class MotionPoll(RESTModelMixin, SlideMixin, CollectDefaultVotesMixin,
self.get_option_class()(poll=self).save() self.get_option_class()(poll=self).save()
def get_percent_base_choice(self): def get_percent_base_choice(self):
return config['motion_poll_100_percent_base'] return config['motions_poll_100_percent_base']
def get_slide_context(self, **context): def get_slide_context(self, **context):
return super(MotionPoll, self).get_slide_context(poll=self) return super(MotionPoll, self).get_slide_context(poll=self)

View File

@ -62,7 +62,7 @@ def motion_to_pdf(pdf, motion):
motion_data.append([cell2a, cell2b]) motion_data.append([cell2a, cell2b])
# supporters # supporters
if config['motion_min_supporters']: if config['motions_min_supporters']:
cell3a = [] cell3a = []
cell3b = [] cell3b = []
cell3a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>" cell3a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>"
@ -201,7 +201,7 @@ def convert_html_to_reportlab(pdf, text):
continue continue
if "<pre>" in paragraph: if "<pre>" in paragraph:
txt = paragraph.replace('\n', '<br/>').replace(' ', '&nbsp;') txt = paragraph.replace('\n', '<br/>').replace(' ', '&nbsp;')
if config["motion_pdf_paragraph_numbering"]: if config["motions_pdf_paragraph_numbering"]:
pdf.append(Paragraph(txt, stylesheet['InnerMonotypeParagraph'], str(paragraph_number))) pdf.append(Paragraph(txt, stylesheet['InnerMonotypeParagraph'], str(paragraph_number)))
paragraph_number += 1 paragraph_number += 1
else: else:
@ -217,7 +217,7 @@ def convert_html_to_reportlab(pdf, text):
elif "<h3>" in paragraph: elif "<h3>" in paragraph:
pdf.append(Paragraph(paragraph, stylesheet['InnerH3Paragraph'])) pdf.append(Paragraph(paragraph, stylesheet['InnerH3Paragraph']))
else: else:
if config["motion_pdf_paragraph_numbering"]: if config["motions_pdf_paragraph_numbering"]:
pdf.append(Paragraph(paragraph, stylesheet['InnerParagraph'], str(paragraph_number))) pdf.append(Paragraph(paragraph, stylesheet['InnerParagraph'], str(paragraph_number)))
paragraph_number += 1 paragraph_number += 1
else: else:
@ -228,9 +228,9 @@ def all_motion_cover(pdf, motions):
""" """
Create a coverpage for all motions. Create a coverpage for all motions.
""" """
pdf.append(Paragraph(escape(config["motion_pdf_title"]), stylesheet['Heading1'])) pdf.append(Paragraph(escape(config["motions_pdf_title"]), stylesheet['Heading1']))
preamble = escape(config["motion_pdf_preamble"]) preamble = escape(config["motions_pdf_preamble"])
if preamble: if preamble:
pdf.append(Paragraph("%s" % preamble.replace('\r\n', '<br/>'), stylesheet['Paragraph'])) pdf.append(Paragraph("%s" % preamble.replace('\r\n', '<br/>'), stylesheet['Paragraph']))
@ -273,8 +273,8 @@ def motion_poll_to_pdf(pdf, poll):
% (circle, _("Abstention")), stylesheet['Ballot_option'])) % (circle, _("Abstention")), stylesheet['Ballot_option']))
data = [] data = []
# get ballot papers config values # get ballot papers config values
ballot_papers_selection = config["motion_pdf_ballot_papers_selection"] ballot_papers_selection = config["motions_pdf_ballot_papers_selection"]
ballot_papers_number = config["motion_pdf_ballot_papers_number"] ballot_papers_number = config["motions_pdf_ballot_papers_number"]
# set number of ballot papers # set number of ballot papers
if ballot_papers_selection == "NUMBER_OF_DELEGATES": if ballot_papers_selection == "NUMBER_OF_DELEGATES":

View File

@ -180,7 +180,7 @@ class MotionSerializer(ModelSerializer):
motion.reason = validated_data.get('reason', '') motion.reason = validated_data.get('reason', '')
motion.identifier = validated_data.get('identifier') motion.identifier = validated_data.get('identifier')
motion.category = validated_data.get('category') motion.category = validated_data.get('category')
motion.reset_state(validated_data.get('workflow', int(config['motion_workflow']))) motion.reset_state(validated_data.get('workflow', int(config['motions_workflow'])))
motion.save() motion.save()
if validated_data['submitters']: if validated_data['submitters']:
motion.submitters.add(*validated_data['submitters']) motion.submitters.add(*validated_data['submitters'])

View File

@ -18,16 +18,16 @@ def setup_motion_config(sender, **kwargs):
the signal openslides.config.signals.config_signal during app loading. the signal openslides.config.signals.config_signal during app loading.
""" """
# General # General
motion_workflow = ConfigVariable( motions_workflow = ConfigVariable(
name='motion_workflow', name='motions_workflow',
default_value='1', default_value='1',
form_field=forms.ChoiceField( form_field=forms.ChoiceField(
widget=forms.Select(), widget=forms.Select(),
label=ugettext_lazy('Workflow of new motions'), label=ugettext_lazy('Workflow of new motions'),
required=True, required=True,
choices=[(str(workflow.pk), ugettext_lazy(workflow.name)) for workflow in Workflow.objects.all()])) choices=[(str(workflow.pk), ugettext_lazy(workflow.name)) for workflow in Workflow.objects.all()]))
motion_identifier = ConfigVariable( motions_identifier = ConfigVariable(
name='motion_identifier', name='motions_identifier',
default_value='per_category', default_value='per_category',
form_field=forms.ChoiceField( form_field=forms.ChoiceField(
widget=forms.Select(), widget=forms.Select(),
@ -37,22 +37,22 @@ def setup_motion_config(sender, **kwargs):
('per_category', ugettext_lazy('Numbered per category')), ('per_category', ugettext_lazy('Numbered per category')),
('serially_numbered', ugettext_lazy('Serially numbered')), ('serially_numbered', ugettext_lazy('Serially numbered')),
('manually', ugettext_lazy('Set it manually'))])) ('manually', ugettext_lazy('Set it manually'))]))
motion_preamble = ConfigVariable( motions_preamble = ConfigVariable(
name='motion_preamble', name='motions_preamble',
default_value=_('The assembly may decide,'), default_value=_('The assembly may decide,'),
translatable=True, translatable=True,
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.TextInput(), widget=forms.TextInput(),
required=False, required=False,
label=ugettext_lazy('Motion preamble'))) label=ugettext_lazy('Motion preamble')))
motion_stop_submitting = ConfigVariable( motions_stop_submitting = ConfigVariable(
name='motion_stop_submitting', name='motions_stop_submitting',
default_value=False, default_value=False,
form_field=forms.BooleanField( form_field=forms.BooleanField(
label=ugettext_lazy('Stop submitting new motions by non-staff users'), label=ugettext_lazy('Stop submitting new motions by non-staff users'),
required=False)) required=False))
motion_allow_disable_versioning = ConfigVariable( motions_allow_disable_versioning = ConfigVariable(
name='motion_allow_disable_versioning', name='motions_allow_disable_versioning',
default_value=False, default_value=False,
form_field=forms.BooleanField( form_field=forms.BooleanField(
label=ugettext_lazy('Allow to disable versioning'), label=ugettext_lazy('Allow to disable versioning'),
@ -60,22 +60,22 @@ def setup_motion_config(sender, **kwargs):
group_general = ConfigGroup( group_general = ConfigGroup(
title=ugettext_lazy('General'), title=ugettext_lazy('General'),
variables=( variables=(
motion_workflow, motions_workflow,
motion_identifier, motions_identifier,
motion_preamble, motions_preamble,
motion_stop_submitting, motions_stop_submitting,
motion_allow_disable_versioning)) motions_allow_disable_versioning))
# Amendments # Amendments
motion_amendments_enabled = ConfigVariable( motions_amendments_enabled = ConfigVariable(
name='motion_amendments_enabled', name='motions_amendments_enabled',
default_value=False, default_value=False,
form_field=forms.BooleanField( form_field=forms.BooleanField(
label=ugettext_lazy('Activate amendments'), label=ugettext_lazy('Activate amendments'),
required=False)) required=False))
motion_amendments_prefix = ConfigVariable( motions_amendments_prefix = ConfigVariable(
name='motion_amendments_prefix', name='motions_amendments_prefix',
default_value=pgettext('Prefix for the identifier for amendments', 'A'), default_value=pgettext('Prefix for the identifier for amendments', 'A'),
form_field=forms.CharField( form_field=forms.CharField(
required=False, required=False,
@ -83,38 +83,38 @@ def setup_motion_config(sender, **kwargs):
group_amendments = ConfigGroup( group_amendments = ConfigGroup(
title=ugettext_lazy('Amendments'), title=ugettext_lazy('Amendments'),
variables=(motion_amendments_enabled, motion_amendments_prefix)) variables=(motions_amendments_enabled, motions_amendments_prefix))
# Supporters # Supporters
motion_min_supporters = ConfigVariable( motions_min_supporters = ConfigVariable(
name='motion_min_supporters', name='motions_min_supporters',
default_value=0, default_value=0,
form_field=forms.IntegerField( form_field=forms.IntegerField(
widget=forms.TextInput(attrs={'class': 'small-input'}), widget=forms.TextInput(attrs={'class': 'small-input'}),
label=ugettext_lazy('Number of (minimum) required supporters for a motion'), label=ugettext_lazy('Number of (minimum) required supporters for a motion'),
min_value=0, min_value=0,
help_text=ugettext_lazy('Choose 0 to disable the supporting system.'))) help_text=ugettext_lazy('Choose 0 to disable the supporting system.')))
motion_remove_supporters = ConfigVariable( motions_remove_supporters = ConfigVariable(
name='motion_remove_supporters', name='motions_remove_supporters',
default_value=False, default_value=False,
form_field=forms.BooleanField( form_field=forms.BooleanField(
label=ugettext_lazy('Remove all supporters of a motion if a submitter edits his motion in early state'), label=ugettext_lazy('Remove all supporters of a motion if a submitter edits his motion in early state'),
required=False)) required=False))
group_supporters = ConfigGroup( group_supporters = ConfigGroup(
title=ugettext_lazy('Supporters'), title=ugettext_lazy('Supporters'),
variables=(motion_min_supporters, motion_remove_supporters)) variables=(motions_min_supporters, motions_remove_supporters))
# Voting and ballot papers # Voting and ballot papers
motion_poll_100_percent_base = ConfigVariable( motions_poll_100_percent_base = ConfigVariable(
name='motion_poll_100_percent_base', name='motions_poll_100_percent_base',
default_value='WITHOUT_INVALID', default_value='WITHOUT_INVALID',
form_field=forms.ChoiceField( form_field=forms.ChoiceField(
widget=forms.Select(), widget=forms.Select(),
required=False, required=False,
label=ugettext_lazy('The 100 % base of a voting result consists of'), label=ugettext_lazy('The 100 % base of a voting result consists of'),
choices=PERCENT_BASE_CHOICES)) choices=PERCENT_BASE_CHOICES))
motion_pdf_ballot_papers_selection = ConfigVariable( motions_pdf_ballot_papers_selection = ConfigVariable(
name='motion_pdf_ballot_papers_selection', name='motions_pdf_ballot_papers_selection',
default_value='CUSTOM_NUMBER', default_value='CUSTOM_NUMBER',
form_field=forms.ChoiceField( form_field=forms.ChoiceField(
widget=forms.Select(), widget=forms.Select(),
@ -124,8 +124,8 @@ def setup_motion_config(sender, **kwargs):
('NUMBER_OF_DELEGATES', ugettext_lazy('Number of all delegates')), ('NUMBER_OF_DELEGATES', ugettext_lazy('Number of all delegates')),
('NUMBER_OF_ALL_PARTICIPANTS', ugettext_lazy('Number of all participants')), ('NUMBER_OF_ALL_PARTICIPANTS', ugettext_lazy('Number of all participants')),
('CUSTOM_NUMBER', ugettext_lazy("Use the following custom number"))])) ('CUSTOM_NUMBER', ugettext_lazy("Use the following custom number"))]))
motion_pdf_ballot_papers_number = ConfigVariable( motions_pdf_ballot_papers_number = ConfigVariable(
name='motion_pdf_ballot_papers_number', name='motions_pdf_ballot_papers_number',
default_value=8, default_value=8,
form_field=forms.IntegerField( form_field=forms.IntegerField(
widget=forms.TextInput(attrs={'class': 'small-input'}), widget=forms.TextInput(attrs={'class': 'small-input'}),
@ -134,33 +134,39 @@ def setup_motion_config(sender, **kwargs):
label=ugettext_lazy('Custom number of ballot papers'))) label=ugettext_lazy('Custom number of ballot papers')))
group_ballot_papers = ConfigGroup( group_ballot_papers = ConfigGroup(
title=ugettext_lazy('Voting and ballot papers'), title=ugettext_lazy('Voting and ballot papers'),
variables=(motion_poll_100_percent_base, motion_pdf_ballot_papers_selection, motion_pdf_ballot_papers_number)) variables=(
motions_poll_100_percent_base,
motions_pdf_ballot_papers_selection,
motions_pdf_ballot_papers_number))
# PDF # PDF
motion_pdf_title = ConfigVariable( motions_pdf_title = ConfigVariable(
name='motion_pdf_title', name='motions_pdf_title',
default_value=_('Motions'), default_value=_('Motions'),
translatable=True, translatable=True,
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.TextInput(), widget=forms.TextInput(),
required=False, required=False,
label=ugettext_lazy('Title for PDF document (all motions)'))) label=ugettext_lazy('Title for PDF document (all motions)')))
motion_pdf_preamble = ConfigVariable( motions_pdf_preamble = ConfigVariable(
name='motion_pdf_preamble', name='motions_pdf_preamble',
default_value='', default_value='',
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.Textarea(), widget=forms.Textarea(),
required=False, required=False,
label=ugettext_lazy('Preamble text for PDF document (all motions)'))) label=ugettext_lazy('Preamble text for PDF document (all motions)')))
motion_pdf_paragraph_numbering = ConfigVariable( motions_pdf_paragraph_numbering = ConfigVariable(
name='motion_pdf_paragraph_numbering', name='motions_pdf_paragraph_numbering',
default_value=False, default_value=False,
form_field=forms.BooleanField( form_field=forms.BooleanField(
label=ugettext_lazy('Show paragraph numbering (only in PDF)'), label=ugettext_lazy('Show paragraph numbering (only in PDF)'),
required=False)) required=False))
group_pdf = ConfigGroup( group_pdf = ConfigGroup(
title=ugettext_lazy('PDF'), title=ugettext_lazy('PDF'),
variables=(motion_pdf_title, motion_pdf_preamble, motion_pdf_paragraph_numbering)) variables=(
motions_pdf_title,
motions_pdf_preamble,
motions_pdf_paragraph_numbering))
return ConfigGroupedCollection( return ConfigGroupedCollection(
title=ugettext_noop('Motion'), title=ugettext_noop('Motion'),

View File

@ -49,12 +49,12 @@ class MotionViewSet(ModelViewSet):
needs at least the permissions 'motions.can_see' (see needs at least the permissions 'motions.can_see' (see
self.check_permission()) and 'motions.can_create'. If the self.check_permission()) and 'motions.can_create'. If the
submitting of new motions by non-staff users is stopped via config submitting of new motions by non-staff users is stopped via config
variable 'motion_stop_submitting', the requesting user needs also variable 'motions_stop_submitting', the requesting user needs also
to have the permission 'motions.can_manage'. to have the permission 'motions.can_manage'.
""" """
# Check permissions. # Check permissions.
if (not request.user.has_perm('motions.can_create') or if (not request.user.has_perm('motions.can_create') or
(not config['motion_stop_submitting'] and (not config['motions_stop_submitting'] and
not request.user.has_perm('motions.can_manage'))): not request.user.has_perm('motions.can_manage'))):
self.permission_denied(request) self.permission_denied(request)
@ -107,7 +107,7 @@ class MotionViewSet(ModelViewSet):
# Write the log message, check removal of supporters and initiate response. # Write the log message, check removal of supporters and initiate response.
# TODO: Log if a version was updated. # TODO: Log if a version was updated.
updated_motion.write_log([ugettext_noop('Motion updated')], request.user) updated_motion.write_log([ugettext_noop('Motion updated')], request.user)
if (config['motion_remove_supporters'] and updated_motion.state.allow_support and if (config['motions_remove_supporters'] and updated_motion.state.allow_support and
not request.user.has_perm('motions.can_manage')): not request.user.has_perm('motions.can_manage')):
updated_motion.supporters.clear() updated_motion.supporters.clear()
updated_motion.write_log([ugettext_noop('All supporters removed')], request.user) updated_motion.write_log([ugettext_noop('All supporters removed')], request.user)

View File

@ -98,12 +98,12 @@ class AnonymousAuthentication(BaseAuthentication):
""" """
Authentication class for the Django REST framework. Authentication class for the Django REST framework.
Sets the user to the our AnonymousUser but only if system_enable_anonymous Sets the user to the our AnonymousUser but only if
is set to True in the config. general_system_enable_anonymous is set to True in the config.
""" """
def authenticate(self, request): def authenticate(self, request):
if config['system_enable_anonymous']: if config['general_system_enable_anonymous']:
return (AnonymousUser(), None) return (AnonymousUser(), None)
return None return None
@ -120,7 +120,7 @@ def get_user(request):
except AttributeError: except AttributeError:
# Get the user. If it is a DjangoAnonymousUser, then use our AnonymousUser # Get the user. If it is a DjangoAnonymousUser, then use our AnonymousUser
return_user = _get_user(request) return_user = _get_user(request)
if config['system_enable_anonymous'] and isinstance(return_user, DjangoAnonymousUser): if config['general_system_enable_anonymous'] and isinstance(return_user, DjangoAnonymousUser):
return_user = AnonymousUser() return_user = AnonymousUser()
request._cached_user = return_user request._cached_user = return_user
return return_user return return_user
@ -139,10 +139,7 @@ def auth(request):
# Change the django anonymous user with our anonymous user if anonymous auth # Change the django anonymous user with our anonymous user if anonymous auth
# is enabled # is enabled
if config['system_enable_anonymous'] and isinstance(context['user'], DjangoAnonymousUser): if config['general_system_enable_anonymous'] and isinstance(context['user'], DjangoAnonymousUser):
context['user'] = AnonymousUser() context['user'] = AnonymousUser()
# Set a context variable that will indicate if anonymous login is possible
context['os_enable_anonymous_login'] = config['system_enable_anonymous']
return context return context

View File

@ -237,14 +237,14 @@ def firstPage(canvas, doc):
canvas.setFont('Ubuntu', 10) canvas.setFont('Ubuntu', 10)
canvas.setFillGray(0.4) canvas.setFillGray(0.4)
title_line = u"%s | %s" % (config["event_name"], title_line = u"%s | %s" % (config["general_event_name"],
config["event_description"]) config["general_event_description"])
if len(title_line) > 75: if len(title_line) > 75:
title_line = "%s ..." % title_line[:70] title_line = "%s ..." % title_line[:70]
canvas.drawString(2.75 * cm, 28 * cm, title_line) canvas.drawString(2.75 * cm, 28 * cm, title_line)
if config["event_date"] and config["event_location"]: if config["general_event_date"] and config["general_event_location"]:
canvas.drawString(2.75 * cm, 27.6 * cm, u"%s, %s" canvas.drawString(2.75 * cm, 27.6 * cm, u"%s, %s"
% (config["event_date"], config["event_location"])) % (config["general_event_date"], config["general_event_location"]))
# time # time
canvas.setFont('Ubuntu', 7) canvas.setFont('Ubuntu', 7)

View File

@ -11,7 +11,7 @@ class AnonymousRequests(TestCase):
""" """
def setUp(self): def setUp(self):
self.client = Client() self.client = Client()
config['system_enable_anonymous'] = True config['general_system_enable_anonymous'] = True
def test_motion_detail(self): def test_motion_detail(self):
Motion.objects.create(title='test_motion') Motion.objects.create(title='test_motion')

View File

@ -99,7 +99,7 @@ class CreateMotion(TestCase):
self.assertEqual(motion.tags.get().name, 'test_tag_iRee3kiecoos4rorohth') self.assertEqual(motion.tags.get().name, 'test_tag_iRee3kiecoos4rorohth')
def test_with_workflow(self): def test_with_workflow(self):
self.assertEqual(config['motion_workflow'], '1') self.assertEqual(config['motions_workflow'], '1')
response = self.client.post( response = self.client.post(
reverse('motion-list'), reverse('motion-list'),
{'title': 'test_title_eemuR5hoo4ru2ahgh5EJ', {'title': 'test_title_eemuR5hoo4ru2ahgh5EJ',
@ -132,7 +132,7 @@ class UpdateMotion(TestCase):
self.assertEqual(motion.identifier, 'test_identifier_jieseghohj7OoSah1Ko9') self.assertEqual(motion.identifier, 'test_identifier_jieseghohj7OoSah1Ko9')
def test_patch_workflow(self): def test_patch_workflow(self):
self.assertEqual(config['motion_workflow'], '1') self.assertEqual(config['motions_workflow'], '1')
response = self.client.patch( response = self.client.patch(
reverse('motion-detail', args=[self.motion.pk]), reverse('motion-detail', args=[self.motion.pk]),
{'workflow': '2'}) {'workflow': '2'})
@ -162,7 +162,7 @@ class UpdateMotion(TestCase):
username='test_username_ahshi4oZin0OoSh9chee', username='test_username_ahshi4oZin0OoSh9chee',
password='test_password_Sia8ahgeenixu5cei2Ib') password='test_password_Sia8ahgeenixu5cei2Ib')
self.motion.supporters.add(supporter) self.motion.supporters.add(supporter)
config['motion_remove_supporters'] = True config['motions_remove_supporters'] = True
self.assertEqual(self.motion.supporters.count(), 1) self.assertEqual(self.motion.supporters.count(), 1)
response = self.client.patch( response = self.client.patch(
@ -234,13 +234,13 @@ class SupportMotion(TestCase):
self.motion.save() self.motion.save()
def test_support(self): def test_support(self):
config['motion_min_supporters'] = 1 config['motions_min_supporters'] = 1
response = self.client.post(reverse('motion-support', args=[self.motion.pk])) response = self.client.post(reverse('motion-support', args=[self.motion.pk]))
self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, {'detail': 'You have supported this motion successfully.'}) self.assertEqual(response.data, {'detail': 'You have supported this motion successfully.'})
def test_unsupport(self): def test_unsupport(self):
config['motion_min_supporters'] = 1 config['motions_min_supporters'] = 1
self.motion.supporters.add(self.admin) self.motion.supporters.add(self.admin)
response = self.client.delete(reverse('motion-support', args=[self.motion.pk])) response = self.client.delete(reverse('motion-support', args=[self.motion.pk]))
self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.status_code, status.HTTP_200_OK)

View File

@ -12,13 +12,13 @@ class TestAnonymousRequests(TestCase):
anonymous user has this permission. anonymous user has this permission.
""" """
@patch('openslides.users.auth.config', {'system_enable_anonymous': True}) @patch('openslides.users.auth.config', {'general_system_enable_anonymous': True})
def test_with_anonymous_user(self): def test_with_anonymous_user(self):
response = self.client.get('/rest/users/user/') response = self.client.get('/rest/users/user/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
@patch('openslides.users.auth.config', {'system_enable_anonymous': False}) @patch('openslides.users.auth.config', {'general_system_enable_anonymous': False})
def test_without_anonymous_user(self): def test_without_anonymous_user(self):
response = self.client.get('/rest/users/user/') response = self.client.get('/rest/users/user/')

View File

@ -146,7 +146,7 @@ class ModelTest(TestCase):
self.assertEqual(str(motion), 'test_identifier_VohT1hu9uhiSh6ooVBFS | test_title_Koowoh1ISheemeey1air') self.assertEqual(str(motion), 'test_identifier_VohT1hu9uhiSh6ooVBFS | test_title_Koowoh1ISheemeey1air')
def test_is_amendment(self): def test_is_amendment(self):
config['motion_amendments_enabled'] = True config['motions_amendments_enabled'] = True
amendment = Motion.objects.create(title='amendment', parent=self.motion) amendment = Motion.objects.create(title='amendment', parent=self.motion)
self.assertTrue(amendment.is_amendment()) self.assertTrue(amendment.is_amendment())
@ -166,7 +166,7 @@ class ModelTest(TestCase):
""" """
If the config is set to manually, the method does nothing. If the config is set to manually, the method does nothing.
""" """
config['motion_identifier'] = 'manually' config['motions_identifier'] = 'manually'
motion = Motion() motion = Motion()
motion.set_identifier() motion.set_identifier()
@ -179,7 +179,7 @@ class ModelTest(TestCase):
If the motion is an amendment, the identifier is the identifier from the If the motion is an amendment, the identifier is the identifier from the
parent + a suffix. parent + a suffix.
""" """
config['motion_amendments_enabled'] = True config['motions_amendments_enabled'] = True
self.motion.identifier = 'Parent identifier' self.motion.identifier = 'Parent identifier'
self.motion.save() self.motion.save()
motion = Motion(parent=self.motion) motion = Motion(parent=self.motion)
@ -193,7 +193,7 @@ class ModelTest(TestCase):
If a motion has already an amendment, the second motion gets another If a motion has already an amendment, the second motion gets another
identifier. identifier.
""" """
config['motion_amendments_enabled'] = True config['motions_amendments_enabled'] = True
self.motion.identifier = 'Parent identifier' self.motion.identifier = 'Parent identifier'
self.motion.save() self.motion.save()
Motion.objects.create(title='Amendment1', parent=self.motion) Motion.objects.create(title='Amendment1', parent=self.motion)
@ -206,4 +206,4 @@ class ModelTest(TestCase):
class ConfigTest(TestCase): class ConfigTest(TestCase):
def test_stop_submitting(self): def test_stop_submitting(self):
self.assertFalse(config['motion_stop_submitting']) self.assertFalse(config['motions_stop_submitting'])

View File

@ -91,6 +91,6 @@ class TestFunctions(TestCase):
self.assertEqual(main.get_database_path_from_settings(), ':memory:') self.assertEqual(main.get_database_path_from_settings(), ':memory:')
def test_translate_customizable_strings(self): def test_translate_customizable_strings(self):
self.assertEqual(config['event_description'], 'Presentation and assembly system') self.assertEqual(config['general_event_description'], 'Presentation and assembly system')
main.translate_customizable_strings('de') main.translate_customizable_strings('de')
self.assertEqual(config['event_description'], u'Präsentations- und Versammlungssystem') self.assertEqual(config['general_event_description'], u'Präsentations- und Versammlungssystem')

View File

@ -112,8 +112,7 @@ class TestAuth(TestCase):
self.assertEqual( self.assertEqual(
context, context,
{'user': AnonymousUser(), {'user': AnonymousUser()})
'os_enable_anonymous_login': True})
def test_anonymous_disabled(self, mock_auth, mock_config): def test_anonymous_disabled(self, mock_auth, mock_config):
mock_config.__getitem__.return_value = False mock_config.__getitem__.return_value = False
@ -124,8 +123,7 @@ class TestAuth(TestCase):
self.assertEqual( self.assertEqual(
context, context,
{'user': AnonymousUser(), {'user': AnonymousUser()})
'os_enable_anonymous_login': False})
def test_logged_in_user_in_request(self, mock_auth, mock_config): def test_logged_in_user_in_request(self, mock_auth, mock_config):
mock_config.__getitem__.return_value = True mock_config.__getitem__.return_value = True
@ -136,5 +134,4 @@ class TestAuth(TestCase):
self.assertEqual( self.assertEqual(
context, context,
{'user': 'logged_in_user', {'user': 'logged_in_user'})
'os_enable_anonymous_login': True})