2013-03-01 17:13:12 +01:00
|
|
|
from django import forms
|
2013-09-25 10:01:01 +02:00
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from django.utils.translation import ugettext_lazy, ugettext_noop
|
2013-03-12 20:58:22 +01:00
|
|
|
|
2014-01-31 00:55:18 +01:00
|
|
|
from openslides.config.api import ConfigGroup, ConfigGroupedCollection, ConfigVariable
|
2013-03-12 20:58:22 +01:00
|
|
|
|
|
|
|
|
2014-10-11 14:34:49 +02:00
|
|
|
def setup_users_config(sender, **kwargs):
|
2013-03-01 17:13:12 +01:00
|
|
|
"""
|
2014-11-13 22:23:16 +01:00
|
|
|
Receiver function to setup all users config variables. It is connected
|
|
|
|
to the signal openslides.config.signals.config_signal during app loading.
|
2013-03-01 17:13:12 +01:00
|
|
|
"""
|
2014-01-31 00:55:18 +01:00
|
|
|
# General
|
2014-10-11 14:34:49 +02:00
|
|
|
users_sort_users_by_first_name = ConfigVariable(
|
|
|
|
name='users_sort_users_by_first_name',
|
2014-01-31 00:55:18 +01:00
|
|
|
default_value=False,
|
|
|
|
form_field=forms.BooleanField(
|
|
|
|
required=False,
|
2014-10-11 14:34:49 +02:00
|
|
|
label=ugettext_lazy('Sort users by first name'),
|
2014-01-31 00:55:18 +01:00
|
|
|
help_text=ugettext_lazy('Disable for sorting by last name')))
|
|
|
|
|
|
|
|
group_general = ConfigGroup(
|
|
|
|
title=ugettext_lazy('Sorting'),
|
2014-10-11 14:34:49 +02:00
|
|
|
variables=(users_sort_users_by_first_name,))
|
2014-01-31 00:55:18 +01:00
|
|
|
|
|
|
|
# PDF
|
2014-10-11 14:34:49 +02:00
|
|
|
users_pdf_welcometitle = ConfigVariable(
|
|
|
|
name='users_pdf_welcometitle',
|
2013-10-23 23:47:25 +02:00
|
|
|
default_value=_('Welcome to OpenSlides!'),
|
2014-01-31 01:54:41 +01:00
|
|
|
translatable=True,
|
2013-03-01 17:13:12 +01:00
|
|
|
form_field=forms.CharField(
|
2013-10-23 23:47:25 +02:00
|
|
|
widget=forms.Textarea(),
|
2013-03-01 17:13:12 +01:00
|
|
|
required=False,
|
2013-10-23 23:47:25 +02:00
|
|
|
label=ugettext_lazy('Title for access data and welcome PDF')))
|
|
|
|
|
2014-10-11 14:34:49 +02:00
|
|
|
users_pdf_welcometext = ConfigVariable(
|
|
|
|
name='users_pdf_welcometext',
|
2013-10-23 23:47:25 +02:00
|
|
|
default_value=_('[Place for your welcome and help text.]'),
|
2014-01-31 01:54:41 +01:00
|
|
|
translatable=True,
|
2013-03-01 17:13:12 +01:00
|
|
|
form_field=forms.CharField(
|
|
|
|
widget=forms.Textarea(),
|
|
|
|
required=False,
|
2013-10-23 23:47:25 +02:00
|
|
|
label=ugettext_lazy('Help text for access data and welcome PDF')))
|
|
|
|
|
2014-10-11 14:34:49 +02:00
|
|
|
users_pdf_url = ConfigVariable(
|
|
|
|
name='users_pdf_url',
|
2014-01-31 00:55:18 +01:00
|
|
|
default_value='http://example.com:8000',
|
|
|
|
form_field=forms.CharField(
|
|
|
|
widget=forms.TextInput(),
|
2013-03-01 17:13:12 +01:00
|
|
|
required=False,
|
2014-01-31 00:55:18 +01:00
|
|
|
label=ugettext_lazy('System URL'),
|
|
|
|
help_text=ugettext_lazy('Used for QRCode in PDF of access data.')))
|
|
|
|
|
2014-10-11 14:34:49 +02:00
|
|
|
users_pdf_wlan_ssid = ConfigVariable(
|
|
|
|
name='users_pdf_wlan_ssid',
|
2014-01-31 00:55:18 +01:00
|
|
|
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.')))
|
|
|
|
|
2014-10-11 14:34:49 +02:00
|
|
|
users_pdf_wlan_password = ConfigVariable(
|
|
|
|
name='users_pdf_wlan_password',
|
2014-01-31 00:55:18 +01:00
|
|
|
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.')))
|
|
|
|
|
2014-10-11 14:34:49 +02:00
|
|
|
users_pdf_wlan_encryption = ConfigVariable(
|
|
|
|
name='users_pdf_wlan_encryption',
|
2014-01-31 00:55:18 +01:00
|
|
|
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'),
|
2014-10-11 14:34:49 +02:00
|
|
|
variables=(users_pdf_welcometitle,
|
|
|
|
users_pdf_welcometext,
|
|
|
|
users_pdf_url,
|
|
|
|
users_pdf_wlan_ssid,
|
|
|
|
users_pdf_wlan_password,
|
|
|
|
users_pdf_wlan_encryption))
|
2013-03-01 17:13:12 +01:00
|
|
|
|
2014-01-31 00:55:18 +01:00
|
|
|
return ConfigGroupedCollection(
|
2014-10-11 14:34:49 +02:00
|
|
|
title=ugettext_noop('Users'),
|
|
|
|
url='users',
|
2014-01-31 00:55:18 +01:00
|
|
|
weight=50,
|
|
|
|
groups=(group_general, group_pdf))
|
2013-03-01 17:13:12 +01:00
|
|
|
|
|
|
|
|
2014-10-11 14:34:49 +02:00
|
|
|
def user_post_save(sender, instance, *args, **kwargs):
|
2014-11-13 22:23:16 +01:00
|
|
|
"""
|
|
|
|
Receiver function to add a new user to the registered group. It is
|
|
|
|
connected to the signal django.db.models.signals.post_save during app
|
|
|
|
loading.
|
|
|
|
"""
|
2014-10-11 14:34:49 +02:00
|
|
|
if not kwargs['created']:
|
|
|
|
return
|
|
|
|
|
|
|
|
from openslides.users.api import get_registered_group # TODO: Test, if global import is possible
|
|
|
|
registered = get_registered_group()
|
|
|
|
instance.groups.add(registered)
|
|
|
|
instance.save()
|