Merge pull request #1210 from normanjaeckel/RegroupConfig

Regrouped config collections and pages. Fixed #1201.
This commit is contained in:
Norman Jäckel 2014-03-13 00:47:52 +01:00
commit fc205a8437
6 changed files with 184 additions and 146 deletions

View File

@ -19,6 +19,7 @@ Other:
- Changed widget api. Used new metaclass.
- Changed api for plugins. Used entry points to detect them automaticly.
- Renamed config api classes.
- Regrouped config collections and pages.
- Renamed some classes of the poll api.
- Inserted command line option to translate config strings during database setup.
- Inserted api for the personal info widget.

View File

@ -5,7 +5,7 @@ from django.dispatch import receiver
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy, ugettext_noop
from openslides.config.api import ConfigCollection, ConfigVariable
from openslides.config.api import ConfigGroup, ConfigGroupedCollection, ConfigVariable
from openslides.config.signals import config_signal
@ -14,13 +14,18 @@ def setup_assignment_config(sender, **kwargs):
"""
Assignment config variables.
"""
assignment_publish_winner_results_only = ConfigVariable(
name='assignment_publish_winner_results_only',
default_value=False,
form_field=forms.BooleanField(
# Ballot and ballot papers
assignment_poll_vote_values = ConfigVariable(
name='assignment_poll_vote_values',
default_value='auto',
form_field=forms.ChoiceField(
widget=forms.Select(),
required=False,
label=ugettext_lazy('Only publish voting results for selected '
'winners (Projector view only)')))
label=ugettext_lazy('Election method'),
choices=(
('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_pdf_ballot_papers_selection = ConfigVariable(
name='assignment_pdf_ballot_papers_selection',
default_value='CUSTOM_NUMBER',
@ -40,6 +45,21 @@ def setup_assignment_config(sender, **kwargs):
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',
default_value=False,
form_field=forms.BooleanField(
required=False,
label=ugettext_lazy('Only publish voting results for selected '
'winners (Projector view only)')))
group_ballot = ConfigGroup(
title=ugettext_lazy('Ballot and ballot papers'),
variables=(assignment_poll_vote_values,
assignment_pdf_ballot_papers_selection,
assignment_pdf_ballot_papers_number,
assignment_publish_winner_results_only))
# PDF
assignment_pdf_title = ConfigVariable(
name='assignment_pdf_title',
default_value=_('Elections'),
@ -55,25 +75,13 @@ def setup_assignment_config(sender, **kwargs):
widget=forms.Textarea(),
required=False,
label=ugettext_lazy('Preamble text for PDF document (all elections)')))
assignment_poll_vote_values = ConfigVariable(
name='assignment_poll_vote_values',
default_value='auto',
form_field=forms.ChoiceField(
widget=forms.Select(),
required=False,
label=ugettext_lazy('Election method'),
choices=(
('auto', ugettext_lazy('Automatic assign of method')),
('votes', ugettext_lazy('Always one option per candidate')),
('yesnoabstain', ugettext_lazy('Always Yes-No-Abstain per candidate')))))
group_pdf = ConfigGroup(
title=ugettext_lazy('PDF'),
variables=(assignment_pdf_title, assignment_pdf_preamble))
return ConfigCollection(title=ugettext_noop('Elections'),
return ConfigGroupedCollection(
title=ugettext_noop('Elections'),
url='assignment',
required_permission='config.can_manage',
weight=40,
variables=(assignment_publish_winner_results_only,
assignment_pdf_ballot_papers_selection,
assignment_pdf_ballot_papers_number,
assignment_pdf_title,
assignment_pdf_preamble,
assignment_poll_vote_values))
groups=(group_ballot, group_pdf))

View File

@ -109,6 +109,7 @@ def setup_general_config(sender, **kwargs):
form_field=forms.CharField(
widget=forms.TextInput(),
label=ugettext_lazy('Title'),
help_text=ugettext_lazy('Also used for the default welcome slide.'),
required=False),
on_change=update_projector)
@ -128,47 +129,6 @@ def setup_general_config(sender, **kwargs):
label=ugettext_lazy('Allow access for anonymous guest users'),
required=False))
system_url = ConfigVariable(
name='system_url',
default_value='http://example.com:8000',
form_field=forms.CharField(
widget=forms.TextInput(),
required=False,
label=ugettext_lazy('System URL'),
help_text=ugettext_lazy('Used for QRCode in PDF of access data.')))
system_wlan_ssid = ConfigVariable(
name='system_wlan_ssid',
default_value='',
form_field=forms.CharField(
widget=forms.TextInput(),
required=False,
label=ugettext_lazy('WLAN name (SSID)'),
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.')))
system_wlan_password = ConfigVariable(
name='system_wlan_password',
default_value='',
form_field=forms.CharField(
widget=forms.TextInput(),
required=False,
label=ugettext_lazy('WLAN password'),
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.')))
system_wlan_encryption = ConfigVariable(
name='system_wlan_encryption',
default_value='',
form_field=forms.ChoiceField(
widget=forms.Select(),
required=False,
label=ugettext_lazy('WLAN encryption'),
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.'),
choices=(
('', '---------'),
('WEP', 'WEP'),
('WPA', 'WPA/WPA2'),
('nopass', ugettext_lazy('No encryption')))))
group_event = ConfigGroup(
title=ugettext_lazy('Event'),
variables=(event_name, event_description, event_date, event_location, event_organizer))
@ -183,7 +143,7 @@ def setup_general_config(sender, **kwargs):
group_system = ConfigGroup(
title=ugettext_lazy('System'),
variables=(system_enable_anonymous, system_url, system_wlan_ssid, system_wlan_password, system_wlan_encryption))
variables=(system_enable_anonymous,))
return ConfigGroupedCollection(
title=ugettext_noop('General'),

View File

@ -5,7 +5,7 @@ from django.dispatch import receiver
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy, ugettext_noop
from openslides.config.api import ConfigCollection, ConfigVariable
from openslides.config.api import ConfigGroup, ConfigGroupedCollection, ConfigVariable
from openslides.config.signals import config_signal
from openslides.core.signals import post_database_setup
@ -17,12 +17,56 @@ def setup_motion_config(sender, **kwargs):
"""
Motion config variables.
"""
# General
motion_workflow = ConfigVariable(
name='motion_workflow',
default_value=1,
form_field=forms.ChoiceField(
widget=forms.Select(),
label=ugettext_lazy('Workflow of new motions'),
required=True,
choices=[(workflow.pk, ugettext_lazy(workflow.name)) for workflow in Workflow.objects.all()]))
motion_identifier = ConfigVariable(
name='motion_identifier',
default_value='per_category',
form_field=forms.ChoiceField(
widget=forms.Select(),
required=True,
label=ugettext_lazy('Identifier'),
choices=[
('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',
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',
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',
default_value=False,
form_field=forms.BooleanField(
label=ugettext_lazy('Allow to disable versioning'),
required=False))
group_general = ConfigGroup(
title=ugettext_lazy('General'),
variables=(
motion_workflow,
motion_identifier,
motion_preamble,
motion_stop_submitting,
motion_allow_disable_versioning))
# Supporters
motion_min_supporters = ConfigVariable(
name='motion_min_supporters',
default_value=0,
@ -37,14 +81,11 @@ def setup_motion_config(sender, **kwargs):
form_field=forms.BooleanField(
label=ugettext_lazy('Remove all supporters of a motion if a submitter edits his motion in early state'),
required=False))
motion_preamble = ConfigVariable(
name='motion_preamble',
default_value=_('The assembly may decide,'),
translatable=True,
form_field=forms.CharField(
widget=forms.TextInput(),
required=False,
label=ugettext_lazy('Motion preamble')))
group_supporters = ConfigGroup(
title=ugettext_lazy('Supporters'),
variables=(motion_min_supporters, motion_remove_supporters))
# Ballot papers
motion_pdf_ballot_papers_selection = ConfigVariable(
name='motion_pdf_ballot_papers_selection',
default_value='CUSTOM_NUMBER',
@ -64,6 +105,11 @@ def setup_motion_config(sender, **kwargs):
required=False,
min_value=1,
label=ugettext_lazy('Custom number of ballot papers')))
group_ballot_papers = ConfigGroup(
title=ugettext_lazy('Ballot papers'),
variables=(motion_pdf_ballot_papers_selection, motion_pdf_ballot_papers_number))
# PDF
motion_pdf_title = ConfigVariable(
name='motion_pdf_title',
default_value=_('Motions'),
@ -85,48 +131,16 @@ def setup_motion_config(sender, **kwargs):
form_field=forms.BooleanField(
label=ugettext_lazy('Show paragraph numbering (only in PDF)'),
required=False))
motion_allow_disable_versioning = ConfigVariable(
name='motion_allow_disable_versioning',
default_value=False,
form_field=forms.BooleanField(
label=ugettext_lazy('Allow to disable versioning'),
required=False))
motion_workflow = ConfigVariable(
name='motion_workflow',
default_value=1,
form_field=forms.ChoiceField(
widget=forms.Select(),
label=ugettext_lazy('Workflow of new motions'),
required=True,
choices=[(workflow.pk, ugettext_lazy(workflow.name)) for workflow in Workflow.objects.all()]))
motion_identifier = ConfigVariable(
name='motion_identifier',
default_value='per_category',
form_field=forms.ChoiceField(
widget=forms.Select(),
required=True,
label=ugettext_lazy('Identifier'),
choices=[
('per_category', ugettext_lazy('Numbered per category')),
('serially_numbered', ugettext_lazy('Serially numbered')),
('manually', ugettext_lazy('Set it manually'))]))
group_pdf = ConfigGroup(
title=ugettext_lazy('PDF'),
variables=(motion_pdf_title, motion_pdf_preamble, motion_pdf_paragraph_numbering))
return ConfigCollection(title=ugettext_noop('Motion'),
return ConfigGroupedCollection(
title=ugettext_noop('Motion'),
url='motion',
required_permission='config.can_manage',
weight=30,
variables=(motion_stop_submitting,
motion_min_supporters,
motion_remove_supporters,
motion_preamble,
motion_pdf_ballot_papers_selection,
motion_pdf_ballot_papers_number,
motion_pdf_title,
motion_pdf_preamble,
motion_pdf_paragraph_numbering,
motion_allow_disable_versioning,
motion_workflow,
motion_identifier))
groups=(group_general, group_supporters, group_ballot_papers, group_pdf))
@receiver(post_database_setup, dispatch_uid='motion_create_builtin_workflows')

View File

@ -54,10 +54,10 @@ def participants_passwords_to_pdf(pdf):
"""
Create access data sheets for all participants as PDF
"""
system_wlan_ssid = config["system_wlan_ssid"] or "-"
system_wlan_password = config["system_wlan_password"] or "-"
system_wlan_encryption = config["system_wlan_encryption"] or "-"
system_url = config["system_url"] or "-"
participant_pdf_wlan_ssid = config["participant_pdf_wlan_ssid"] or "-"
participant_pdf_wlan_password = config["participant_pdf_wlan_password"] or "-"
participant_pdf_wlan_encryption = config["participant_pdf_wlan_encryption"] or "-"
participant_pdf_url = config["participant_pdf_url"] or "-"
participant_pdf_welcometitle = config["participant_pdf_welcometitle"]
participant_pdf_welcometext = config["participant_pdf_welcometext"]
if config['participant_sort_users_by_first_name']:
@ -66,14 +66,14 @@ def participants_passwords_to_pdf(pdf):
sort = 'last_name'
qrcode_size = 2 * cm
# qrcode for system url
qrcode_url = QrCodeWidget(system_url)
qrcode_url = QrCodeWidget(participant_pdf_url)
qrcode_url.barHeight = qrcode_size
qrcode_url.barWidth = qrcode_size
qrcode_url.barBorder = 0
qrcode_url_draw = Drawing(45, 45)
qrcode_url_draw.add(qrcode_url)
# qrcode for wlan
text = "WIFI:S:%s;T:%s;P:%s;;" % (system_wlan_ssid, system_wlan_encryption, system_wlan_password)
text = "WIFI:S:%s;T:%s;P:%s;;" % (participant_pdf_wlan_ssid, participant_pdf_wlan_encryption, participant_pdf_wlan_password)
qrcode_wlan = QrCodeWidget(text)
qrcode_wlan.barHeight = qrcode_size
qrcode_wlan.barWidth = qrcode_size
@ -91,15 +91,15 @@ def participants_passwords_to_pdf(pdf):
stylesheet['h2']))
cell.append(Paragraph("%s:" % _("WLAN name (SSID)"),
stylesheet['formfield']))
cell.append(Paragraph(system_wlan_ssid,
cell.append(Paragraph(participant_pdf_wlan_ssid,
stylesheet['formfield_value']))
cell.append(Paragraph("%s:" % _("WLAN password"),
stylesheet['formfield']))
cell.append(Paragraph(system_wlan_password,
cell.append(Paragraph(participant_pdf_wlan_password,
stylesheet['formfield_value']))
cell.append(Paragraph("%s:" % _("WLAN encryption"),
stylesheet['formfield']))
cell.append(Paragraph(system_wlan_encryption,
cell.append(Paragraph(participant_pdf_wlan_encryption,
stylesheet['formfield_value']))
cell.append(Spacer(0, 0.5 * cm))
# OpenSlides access data
@ -116,17 +116,17 @@ def participants_passwords_to_pdf(pdf):
stylesheet['formfield_value']))
cell2.append(Paragraph("URL:",
stylesheet['formfield']))
cell2.append(Paragraph(system_url,
cell2.append(Paragraph(participant_pdf_url,
stylesheet['formfield_value']))
data.append([cell, cell2])
# QRCodes
cell = []
if system_wlan_ssid != "-" and system_wlan_encryption != "-":
if participant_pdf_wlan_ssid != "-" and participant_pdf_wlan_encryption != "-":
cell.append(qrcode_wlan_draw)
cell.append(Paragraph(_("Scan this QRCode to connect WLAN."),
stylesheet['qrcode_comment']))
cell2 = []
if system_url != "-":
if participant_pdf_url != "-":
cell2.append(qrcode_url_draw)
cell2.append(Paragraph(_("Scan this QRCode to open URL."),
stylesheet['qrcode_comment']))

View File

@ -7,7 +7,7 @@ from django.dispatch import receiver
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy, ugettext_noop
from openslides.config.api import ConfigCollection, ConfigVariable
from openslides.config.api import ConfigGroup, ConfigGroupedCollection, ConfigVariable
from openslides.config.signals import config_signal
from openslides.core.signals import post_database_setup
@ -20,6 +20,20 @@ def setup_participant_config(sender, **kwargs):
"""
Participant config variables.
"""
# General
participant_sort_users_by_first_name = ConfigVariable(
name='participant_sort_users_by_first_name',
default_value=False,
form_field=forms.BooleanField(
required=False,
label=ugettext_lazy('Sort participants by first name'),
help_text=ugettext_lazy('Disable for sorting by last name')))
group_general = ConfigGroup(
title=ugettext_lazy('Sorting'),
variables=(participant_sort_users_by_first_name,))
# PDF
participant_pdf_welcometitle = ConfigVariable(
name='participant_pdf_welcometitle',
default_value=_('Welcome to OpenSlides!'),
@ -38,21 +52,62 @@ def setup_participant_config(sender, **kwargs):
required=False,
label=ugettext_lazy('Help text for access data and welcome PDF')))
participant_sort_users_by_first_name = ConfigVariable(
name='participant_sort_users_by_first_name',
default_value=False,
form_field=forms.BooleanField(
participant_pdf_url = ConfigVariable(
name='participant_pdf_url',
default_value='http://example.com:8000',
form_field=forms.CharField(
widget=forms.TextInput(),
required=False,
label=ugettext_lazy('Sort participants by first name'),
help_text=ugettext_lazy('Disable for sorting by last name')))
label=ugettext_lazy('System URL'),
help_text=ugettext_lazy('Used for QRCode in PDF of access data.')))
return ConfigCollection(title=ugettext_noop('Participant'),
participant_pdf_wlan_ssid = ConfigVariable(
name='participant_pdf_wlan_ssid',
default_value='',
form_field=forms.CharField(
widget=forms.TextInput(),
required=False,
label=ugettext_lazy('WLAN name (SSID)'),
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.')))
participant_pdf_wlan_password = ConfigVariable(
name='participant_pdf_wlan_password',
default_value='',
form_field=forms.CharField(
widget=forms.TextInput(),
required=False,
label=ugettext_lazy('WLAN password'),
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.')))
participant_pdf_wlan_encryption = ConfigVariable(
name='participant_pdf_wlan_encryption',
default_value='',
form_field=forms.ChoiceField(
widget=forms.Select(),
required=False,
label=ugettext_lazy('WLAN encryption'),
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.'),
choices=(
('', '---------'),
('WEP', 'WEP'),
('WPA', 'WPA/WPA2'),
('nopass', ugettext_lazy('No encryption')))))
group_pdf = ConfigGroup(
title=ugettext_lazy('PDF'),
variables=(participant_pdf_welcometitle,
participant_pdf_welcometext,
participant_pdf_url,
participant_pdf_wlan_ssid,
participant_pdf_wlan_password,
participant_pdf_wlan_encryption))
return ConfigGroupedCollection(
title=ugettext_noop('Participant'),
url='participant',
required_permission='config.can_manage',
weight=50,
variables=(participant_pdf_welcometitle,
participant_pdf_welcometext,
participant_sort_users_by_first_name))
groups=(group_general, group_pdf))
@receiver(post_database_setup, dispatch_uid='participant_create_builtin_groups_and_admin')