Regrouped config collections and pages. Fixed #1201.

This commit is contained in:
Norman Jäckel 2014-01-31 00:55:18 +01:00
parent a6fa8457cc
commit e7f67457db
6 changed files with 184 additions and 146 deletions

View File

@ -19,6 +19,7 @@ Other:
- Changed widget api. Used new metaclass. - Changed widget api. Used new metaclass.
- Changed api for plugins. Used entry points to detect them automaticly. - Changed api for plugins. Used entry points to detect them automaticly.
- Renamed config api classes. - Renamed config api classes.
- Regrouped config collections and pages.
- Renamed some classes of the poll api. - Renamed some classes of the poll api.
- Inserted command line option to translate config strings during database setup. - Inserted command line option to translate config strings during database setup.
- Inserted api for the personal info widget. - 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 as _
from django.utils.translation import ugettext_lazy, ugettext_noop 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.config.signals import config_signal
@ -14,13 +14,18 @@ def setup_assignment_config(sender, **kwargs):
""" """
Assignment config variables. Assignment config variables.
""" """
assignment_publish_winner_results_only = ConfigVariable( # Ballot and ballot papers
name='assignment_publish_winner_results_only', assignment_poll_vote_values = ConfigVariable(
default_value=False, name='assignment_poll_vote_values',
form_field=forms.BooleanField( default_value='auto',
form_field=forms.ChoiceField(
widget=forms.Select(),
required=False, required=False,
label=ugettext_lazy('Only publish voting results for selected ' label=ugettext_lazy('Election method'),
'winners (Projector view only)'))) 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( assignment_pdf_ballot_papers_selection = ConfigVariable(
name='assignment_pdf_ballot_papers_selection', name='assignment_pdf_ballot_papers_selection',
default_value='CUSTOM_NUMBER', default_value='CUSTOM_NUMBER',
@ -40,6 +45,21 @@ def setup_assignment_config(sender, **kwargs):
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(
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( assignment_pdf_title = ConfigVariable(
name='assignment_pdf_title', name='assignment_pdf_title',
default_value=_('Elections'), default_value=_('Elections'),
@ -55,25 +75,13 @@ def setup_assignment_config(sender, **kwargs):
widget=forms.Textarea(), widget=forms.Textarea(),
required=False, required=False,
label=ugettext_lazy('Preamble text for PDF document (all elections)'))) label=ugettext_lazy('Preamble text for PDF document (all elections)')))
assignment_poll_vote_values = ConfigVariable( group_pdf = ConfigGroup(
name='assignment_poll_vote_values', title=ugettext_lazy('PDF'),
default_value='auto', variables=(assignment_pdf_title, assignment_pdf_preamble))
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')))))
return ConfigCollection(title=ugettext_noop('Elections'), return ConfigGroupedCollection(
title=ugettext_noop('Elections'),
url='assignment', url='assignment',
required_permission='config.can_manage', required_permission='config.can_manage',
weight=40, weight=40,
variables=(assignment_publish_winner_results_only, groups=(group_ballot, group_pdf))
assignment_pdf_ballot_papers_selection,
assignment_pdf_ballot_papers_number,
assignment_pdf_title,
assignment_pdf_preamble,
assignment_poll_vote_values))

View File

@ -109,6 +109,7 @@ def setup_general_config(sender, **kwargs):
form_field=forms.CharField( form_field=forms.CharField(
widget=forms.TextInput(), widget=forms.TextInput(),
label=ugettext_lazy('Title'), label=ugettext_lazy('Title'),
help_text=ugettext_lazy('Also used for the default welcome slide.'),
required=False), required=False),
on_change=update_projector) on_change=update_projector)
@ -128,47 +129,6 @@ def setup_general_config(sender, **kwargs):
label=ugettext_lazy('Allow access for anonymous guest users'), label=ugettext_lazy('Allow access for anonymous guest users'),
required=False)) 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( group_event = ConfigGroup(
title=ugettext_lazy('Event'), title=ugettext_lazy('Event'),
variables=(event_name, event_description, event_date, event_location, event_organizer)) variables=(event_name, event_description, event_date, event_location, event_organizer))
@ -183,7 +143,7 @@ def setup_general_config(sender, **kwargs):
group_system = ConfigGroup( group_system = ConfigGroup(
title=ugettext_lazy('System'), 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( return ConfigGroupedCollection(
title=ugettext_noop('General'), 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 as _
from django.utils.translation import ugettext_lazy, ugettext_noop 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.config.signals import config_signal
from openslides.core.signals import post_database_setup from openslides.core.signals import post_database_setup
@ -17,12 +17,56 @@ def setup_motion_config(sender, **kwargs):
""" """
Motion config variables. 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( motion_stop_submitting = ConfigVariable(
name='motion_stop_submitting', name='motion_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(
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( motion_min_supporters = ConfigVariable(
name='motion_min_supporters', name='motion_min_supporters',
default_value=0, default_value=0,
@ -37,14 +81,11 @@ def setup_motion_config(sender, **kwargs):
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))
motion_preamble = ConfigVariable( group_supporters = ConfigGroup(
name='motion_preamble', title=ugettext_lazy('Supporters'),
default_value=_('The assembly may decide,'), variables=(motion_min_supporters, motion_remove_supporters))
translatable=True,
form_field=forms.CharField( # Ballot papers
widget=forms.TextInput(),
required=False,
label=ugettext_lazy('Motion preamble')))
motion_pdf_ballot_papers_selection = ConfigVariable( motion_pdf_ballot_papers_selection = ConfigVariable(
name='motion_pdf_ballot_papers_selection', name='motion_pdf_ballot_papers_selection',
default_value='CUSTOM_NUMBER', default_value='CUSTOM_NUMBER',
@ -64,6 +105,11 @@ def setup_motion_config(sender, **kwargs):
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')))
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( motion_pdf_title = ConfigVariable(
name='motion_pdf_title', name='motion_pdf_title',
default_value=_('Motions'), default_value=_('Motions'),
@ -85,48 +131,16 @@ def setup_motion_config(sender, **kwargs):
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))
motion_allow_disable_versioning = ConfigVariable( group_pdf = ConfigGroup(
name='motion_allow_disable_versioning', title=ugettext_lazy('PDF'),
default_value=False, variables=(motion_pdf_title, motion_pdf_preamble, motion_pdf_paragraph_numbering))
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'))]))
return ConfigCollection(title=ugettext_noop('Motion'), return ConfigGroupedCollection(
title=ugettext_noop('Motion'),
url='motion', url='motion',
required_permission='config.can_manage', required_permission='config.can_manage',
weight=30, weight=30,
variables=(motion_stop_submitting, groups=(group_general, group_supporters, group_ballot_papers, group_pdf))
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))
@receiver(post_database_setup, dispatch_uid='motion_create_builtin_workflows') @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 Create access data sheets for all participants as PDF
""" """
system_wlan_ssid = config["system_wlan_ssid"] or "-" participant_pdf_wlan_ssid = config["participant_pdf_wlan_ssid"] or "-"
system_wlan_password = config["system_wlan_password"] or "-" participant_pdf_wlan_password = config["participant_pdf_wlan_password"] or "-"
system_wlan_encryption = config["system_wlan_encryption"] or "-" participant_pdf_wlan_encryption = config["participant_pdf_wlan_encryption"] or "-"
system_url = config["system_url"] or "-" participant_pdf_url = config["participant_pdf_url"] or "-"
participant_pdf_welcometitle = config["participant_pdf_welcometitle"] participant_pdf_welcometitle = config["participant_pdf_welcometitle"]
participant_pdf_welcometext = config["participant_pdf_welcometext"] participant_pdf_welcometext = config["participant_pdf_welcometext"]
if config['participant_sort_users_by_first_name']: if config['participant_sort_users_by_first_name']:
@ -66,14 +66,14 @@ def participants_passwords_to_pdf(pdf):
sort = 'last_name' sort = 'last_name'
qrcode_size = 2 * cm qrcode_size = 2 * cm
# qrcode for system url # qrcode for system url
qrcode_url = QrCodeWidget(system_url) qrcode_url = QrCodeWidget(participant_pdf_url)
qrcode_url.barHeight = qrcode_size qrcode_url.barHeight = qrcode_size
qrcode_url.barWidth = qrcode_size qrcode_url.barWidth = qrcode_size
qrcode_url.barBorder = 0 qrcode_url.barBorder = 0
qrcode_url_draw = Drawing(45, 45) qrcode_url_draw = Drawing(45, 45)
qrcode_url_draw.add(qrcode_url) qrcode_url_draw.add(qrcode_url)
# qrcode for wlan # 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 = QrCodeWidget(text)
qrcode_wlan.barHeight = qrcode_size qrcode_wlan.barHeight = qrcode_size
qrcode_wlan.barWidth = qrcode_size qrcode_wlan.barWidth = qrcode_size
@ -91,15 +91,15 @@ def participants_passwords_to_pdf(pdf):
stylesheet['h2'])) stylesheet['h2']))
cell.append(Paragraph("%s:" % _("WLAN name (SSID)"), cell.append(Paragraph("%s:" % _("WLAN name (SSID)"),
stylesheet['formfield'])) stylesheet['formfield']))
cell.append(Paragraph(system_wlan_ssid, cell.append(Paragraph(participant_pdf_wlan_ssid,
stylesheet['formfield_value'])) stylesheet['formfield_value']))
cell.append(Paragraph("%s:" % _("WLAN password"), cell.append(Paragraph("%s:" % _("WLAN password"),
stylesheet['formfield'])) stylesheet['formfield']))
cell.append(Paragraph(system_wlan_password, cell.append(Paragraph(participant_pdf_wlan_password,
stylesheet['formfield_value'])) stylesheet['formfield_value']))
cell.append(Paragraph("%s:" % _("WLAN encryption"), cell.append(Paragraph("%s:" % _("WLAN encryption"),
stylesheet['formfield'])) stylesheet['formfield']))
cell.append(Paragraph(system_wlan_encryption, cell.append(Paragraph(participant_pdf_wlan_encryption,
stylesheet['formfield_value'])) stylesheet['formfield_value']))
cell.append(Spacer(0, 0.5 * cm)) cell.append(Spacer(0, 0.5 * cm))
# OpenSlides access data # OpenSlides access data
@ -116,17 +116,17 @@ def participants_passwords_to_pdf(pdf):
stylesheet['formfield_value'])) stylesheet['formfield_value']))
cell2.append(Paragraph("URL:", cell2.append(Paragraph("URL:",
stylesheet['formfield'])) stylesheet['formfield']))
cell2.append(Paragraph(system_url, cell2.append(Paragraph(participant_pdf_url,
stylesheet['formfield_value'])) stylesheet['formfield_value']))
data.append([cell, cell2]) data.append([cell, cell2])
# QRCodes # QRCodes
cell = [] 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(qrcode_wlan_draw)
cell.append(Paragraph(_("Scan this QRCode to connect WLAN."), cell.append(Paragraph(_("Scan this QRCode to connect WLAN."),
stylesheet['qrcode_comment'])) stylesheet['qrcode_comment']))
cell2 = [] cell2 = []
if system_url != "-": if participant_pdf_url != "-":
cell2.append(qrcode_url_draw) cell2.append(qrcode_url_draw)
cell2.append(Paragraph(_("Scan this QRCode to open URL."), cell2.append(Paragraph(_("Scan this QRCode to open URL."),
stylesheet['qrcode_comment'])) 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 as _
from django.utils.translation import ugettext_lazy, ugettext_noop 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.config.signals import config_signal
from openslides.core.signals import post_database_setup from openslides.core.signals import post_database_setup
@ -20,6 +20,20 @@ def setup_participant_config(sender, **kwargs):
""" """
Participant config variables. 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( participant_pdf_welcometitle = ConfigVariable(
name='participant_pdf_welcometitle', name='participant_pdf_welcometitle',
default_value=_('Welcome to OpenSlides!'), default_value=_('Welcome to OpenSlides!'),
@ -38,21 +52,62 @@ def setup_participant_config(sender, **kwargs):
required=False, required=False,
label=ugettext_lazy('Help text for access data and welcome PDF'))) label=ugettext_lazy('Help text for access data and welcome PDF')))
participant_sort_users_by_first_name = ConfigVariable( participant_pdf_url = ConfigVariable(
name='participant_sort_users_by_first_name', name='participant_pdf_url',
default_value=False, default_value='http://example.com:8000',
form_field=forms.BooleanField( form_field=forms.CharField(
widget=forms.TextInput(),
required=False, required=False,
label=ugettext_lazy('Sort participants by first name'), label=ugettext_lazy('System URL'),
help_text=ugettext_lazy('Disable for sorting by last name'))) 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', url='participant',
required_permission='config.can_manage', required_permission='config.can_manage',
weight=50, weight=50,
variables=(participant_pdf_welcometitle, groups=(group_general, group_pdf))
participant_pdf_welcometext,
participant_sort_users_by_first_name))
@receiver(post_database_setup, dispatch_uid='participant_create_builtin_groups_and_admin') @receiver(post_database_setup, dispatch_uid='participant_create_builtin_groups_and_admin')