Merge pull request #1545 from normanjaeckel/Config

Renamed config variables. Fixed error in settings.
This commit is contained in:
Norman Jäckel 2015-06-17 13:14:28 +02:00
commit 2eed3dea4b
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()
# 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')

View File

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

View File

@ -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', '<br/>'),
@ -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":

View File

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

View File

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

View File

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

View File

@ -217,7 +217,7 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
it is not set yet.
"""
# 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.
return
@ -226,7 +226,7 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
motions = self.parent.amendments.all()
# 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)
# 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
if self.is_amendment():
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:
prefix = ''
else:
@ -440,8 +440,8 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
elif self.state:
new_state = self.state.workflow.first_state
else:
new_state = (Workflow.objects.get(pk=config['motion_workflow']).first_state or
Workflow.objects.get(pk=config['motion_workflow']).state_set.all()[0])
new_state = (Workflow.objects.get(pk=config['motions_workflow']).first_state or
Workflow.objects.get(pk=config['motions_workflow']).state_set.all()[0])
self.set_state(new_state)
def get_agenda_title(self):
@ -488,7 +488,7 @@ class Motion(RESTModelMixin, SlideMixin, models.Model):
self.state.allow_create_poll),
'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_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
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):
@ -697,7 +697,7 @@ class MotionPoll(RESTModelMixin, SlideMixin, CollectDefaultVotesMixin,
self.get_option_class()(poll=self).save()
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):
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])
# supporters
if config['motion_min_supporters']:
if config['motions_min_supporters']:
cell3a = []
cell3b = []
cell3a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>"
@ -201,7 +201,7 @@ def convert_html_to_reportlab(pdf, text):
continue
if "<pre>" in paragraph:
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)))
paragraph_number += 1
else:
@ -217,7 +217,7 @@ def convert_html_to_reportlab(pdf, text):
elif "<h3>" in paragraph:
pdf.append(Paragraph(paragraph, stylesheet['InnerH3Paragraph']))
else:
if config["motion_pdf_paragraph_numbering"]:
if config["motions_pdf_paragraph_numbering"]:
pdf.append(Paragraph(paragraph, stylesheet['InnerParagraph'], str(paragraph_number)))
paragraph_number += 1
else:
@ -228,9 +228,9 @@ def all_motion_cover(pdf, 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:
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']))
data = []
# get ballot papers config values
ballot_papers_selection = config["motion_pdf_ballot_papers_selection"]
ballot_papers_number = config["motion_pdf_ballot_papers_number"]
ballot_papers_selection = config["motions_pdf_ballot_papers_selection"]
ballot_papers_number = config["motions_pdf_ballot_papers_number"]
# set number of ballot papers
if ballot_papers_selection == "NUMBER_OF_DELEGATES":

View File

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

View File

@ -49,12 +49,12 @@ class MotionViewSet(ModelViewSet):
needs at least the permissions 'motions.can_see' (see
self.check_permission()) and 'motions.can_create'. If the
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'.
"""
# Check permissions.
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'))):
self.permission_denied(request)
@ -107,7 +107,7 @@ class MotionViewSet(ModelViewSet):
# Write the log message, check removal of supporters and initiate response.
# TODO: Log if a version was updated.
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')):
updated_motion.supporters.clear()
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.
Sets the user to the our AnonymousUser but only if system_enable_anonymous
is set to True in the config.
Sets the user to the our AnonymousUser but only if
general_system_enable_anonymous is set to True in the config.
"""
def authenticate(self, request):
if config['system_enable_anonymous']:
if config['general_system_enable_anonymous']:
return (AnonymousUser(), None)
return None
@ -120,7 +120,7 @@ def get_user(request):
except AttributeError:
# Get the user. If it is a DjangoAnonymousUser, then use our AnonymousUser
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()
request._cached_user = return_user
return return_user
@ -139,10 +139,7 @@ def auth(request):
# Change the django anonymous user with our anonymous user if anonymous auth
# 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()
# Set a context variable that will indicate if anonymous login is possible
context['os_enable_anonymous_login'] = config['system_enable_anonymous']
return context

View File

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

View File

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

View File

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

View File

@ -12,13 +12,13 @@ class TestAnonymousRequests(TestCase):
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):
response = self.client.get('/rest/users/user/')
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):
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')
def test_is_amendment(self):
config['motion_amendments_enabled'] = True
config['motions_amendments_enabled'] = True
amendment = Motion.objects.create(title='amendment', parent=self.motion)
self.assertTrue(amendment.is_amendment())
@ -166,7 +166,7 @@ class ModelTest(TestCase):
"""
If the config is set to manually, the method does nothing.
"""
config['motion_identifier'] = 'manually'
config['motions_identifier'] = 'manually'
motion = Motion()
motion.set_identifier()
@ -179,7 +179,7 @@ class ModelTest(TestCase):
If the motion is an amendment, the identifier is the identifier from the
parent + a suffix.
"""
config['motion_amendments_enabled'] = True
config['motions_amendments_enabled'] = True
self.motion.identifier = 'Parent identifier'
self.motion.save()
motion = Motion(parent=self.motion)
@ -193,7 +193,7 @@ class ModelTest(TestCase):
If a motion has already an amendment, the second motion gets another
identifier.
"""
config['motion_amendments_enabled'] = True
config['motions_amendments_enabled'] = True
self.motion.identifier = 'Parent identifier'
self.motion.save()
Motion.objects.create(title='Amendment1', parent=self.motion)
@ -206,4 +206,4 @@ class ModelTest(TestCase):
class ConfigTest(TestCase):
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:')
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')
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(
context,
{'user': AnonymousUser(),
'os_enable_anonymous_login': True})
{'user': AnonymousUser()})
def test_anonymous_disabled(self, mock_auth, mock_config):
mock_config.__getitem__.return_value = False
@ -124,8 +123,7 @@ class TestAuth(TestCase):
self.assertEqual(
context,
{'user': AnonymousUser(),
'os_enable_anonymous_login': False})
{'user': AnonymousUser()})
def test_logged_in_user_in_request(self, mock_auth, mock_config):
mock_config.__getitem__.return_value = True
@ -136,5 +134,4 @@ class TestAuth(TestCase):
self.assertEqual(
context,
{'user': 'logged_in_user',
'os_enable_anonymous_login': True})
{'user': 'logged_in_user'})