From 95d5929449bb34c6884da1e8abf2aebdab74574d Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Sun, 15 Apr 2012 12:39:28 +0200 Subject: [PATCH] Added participant and version config page. Moved system settings to general. Some style work. --- .../agenda/templates/agenda/config.html | 2 +- .../templates/application/config.html | 2 +- .../templates/assignment/config.html | 2 +- openslides/config/forms.py | 9 +- openslides/config/models.py | 2 - .../config/templates/config/general.html | 32 ++- openslides/config/views.py | 53 ++-- openslides/locale/de/LC_MESSAGES/django.mo | Bin 30384 -> 30104 bytes openslides/locale/de/LC_MESSAGES/django.po | 227 +++++++++--------- openslides/participant/forms.py | 17 +- openslides/participant/models.py | 12 + .../templates/participant}/config.html | 9 +- openslides/participant/views.py | 21 +- openslides/static/styles/base.css | 6 + openslides/utils/pdf.py | 10 +- 15 files changed, 230 insertions(+), 174 deletions(-) rename openslides/{config/templates/config => participant/templates/participant}/config.html (68%) diff --git a/openslides/agenda/templates/agenda/config.html b/openslides/agenda/templates/agenda/config.html index 4e738721d..bb76b4299 100644 --- a/openslides/agenda/templates/agenda/config.html +++ b/openslides/agenda/templates/agenda/config.html @@ -2,7 +2,7 @@ {% load i18n %} -{% block title %}{{ block.super }} - {% trans "Configuration" %}{% endblock %} +{% block title %}{{ block.super }} - {% trans "Agenda settings" %}{% endblock %} {% block content %}

{%trans "Agenda settings" %}

diff --git a/openslides/application/templates/application/config.html b/openslides/application/templates/application/config.html index 2fc58d7b2..0c7cef797 100644 --- a/openslides/application/templates/application/config.html +++ b/openslides/application/templates/application/config.html @@ -2,7 +2,7 @@ {% load i18n %} -{% block title %}{{ block.super }} - {% trans "Configuration" %}{% endblock %} +{% block title %}{{ block.super }} - {% trans "Application settings" %}{% endblock %} {% block content %}

{%trans "Application settings" %}

diff --git a/openslides/assignment/templates/assignment/config.html b/openslides/assignment/templates/assignment/config.html index edb32fd6b..4db8cee13 100644 --- a/openslides/assignment/templates/assignment/config.html +++ b/openslides/assignment/templates/assignment/config.html @@ -2,7 +2,7 @@ {% load i18n %} -{% block title %}{{ block.super }} - {% trans "Configuration" %}{% endblock %} +{% block title %}{{ block.super }} - {% trans "Election settings" %}{% endblock %} {% block content %}

{%trans "Election settings" %}

diff --git a/openslides/config/forms.py b/openslides/config/forms.py index b17f54558..24ee17a54 100644 --- a/openslides/config/forms.py +++ b/openslides/config/forms.py @@ -17,15 +17,10 @@ from utils.forms import CssClassMixin from models import config -class SystemConfigForm(Form, CssClassMixin): - system_url = CharField(widget=TextInput(), required=False, label=_("System URL")) - system_welcometext = CharField(widget=Textarea(), required=False, label=_("Welcome text (for password PDF)")) - system_enable_anonymous = BooleanField(required=False, label=_("Access for anonymous / guest users"), help_text=_("Allow access for guest users")) - - -class EventConfigForm(Form, CssClassMixin): +class GeneralConfigForm(Form, CssClassMixin): event_name = CharField(widget=TextInput(),label=_("Event name"), max_length=30) event_description = CharField(widget=TextInput(),label=_("Short description of event"), max_length=100, required=False) event_date = CharField(widget=TextInput(), required=False, label=_("Event date")) event_location = CharField(widget=TextInput(), required=False, label=_("Event location")) event_organizer = CharField(widget=TextInput(), required=False, label=_("Event organizer")) + system_enable_anonymous = BooleanField(required=False, label=_("Allow access for anonymous guest users") ) diff --git a/openslides/config/models.py b/openslides/config/models.py index 39cf378bd..0c59315e5 100644 --- a/openslides/config/models.py +++ b/openslides/config/models.py @@ -81,8 +81,6 @@ def default_config(sender, key, **kwargs): return { 'event_name': 'OpenSlides', 'event_description': 'Presentation and voting system', - 'system_url': 'http://127.0.0.1:8000', - 'system_welcometext': 'Welcome to OpenSlides!', }.get(key) diff --git a/openslides/config/templates/config/general.html b/openslides/config/templates/config/general.html index 1a7e7a502..9a6c29132 100644 --- a/openslides/config/templates/config/general.html +++ b/openslides/config/templates/config/general.html @@ -2,12 +2,40 @@ {% load i18n %} -{% block title %}{{ block.super }} - {% trans "Configuration" %}{% endblock %} +{% block title %}{{ block.super }} - {% trans "General settings" %}{% endblock %} {% block content %}

{%trans "General settings" %}

{% csrf_token %} - {{ form.as_p }} +
+ {%trans "Event" %} + {% for field in form %} + {% if "id_event" in field.label_tag %} +

+ {{ field.errors }} + {{ field.required }} + {{ field.label_tag }} + {{ field }} + {{ field.help_text }} +

+ {% endif %} + {% endfor %} +
+

+
+ {%trans "System" %} + {% for field in form %} + {% if "id_system" in field.label_tag %} +

+ {{ field.errors }} + {{ field.required }} + {{ field.label_tag }} + {{ field }} + {{ field.help_text }} +

+ {% endif %} + {% endfor %} +

- - diff --git a/openslides/participant/views.py b/openslides/participant/views.py index e6bb42077..6e0425a3f 100644 --- a/openslides/participant/views.py +++ b/openslides/participant/views.py @@ -36,12 +36,13 @@ from participant.models import Profile from participant.api import gen_username, gen_password from participant.forms import (UserNewForm, UserEditForm, ProfileForm, UsersettingsForm, UserImportForm, GroupForm, - AdminPasswordChangeForm) + AdminPasswordChangeForm, ConfigForm) from application.models import Application from utils.utils import (template, permission_required, gen_confirm_form, ajax_request, decodedict, encodedict) from utils.pdf import print_userlist, print_passwords from utils.template import Tab +from utils.views import FormView from config.models import config from django.db.models import Avg, Max, Min, Count @@ -482,3 +483,21 @@ def register_tab(request): permission=request.user.has_perm('participant.can_see_participant') or request.user.has_perm('participant.can_manage_participant'), selected=selected, ) + + +class Config(FormView): + permission_required = 'config.can_manage_config' + form_class = ConfigForm + template_name = 'participant/config.html' + + def get_initial(self): + return { + 'participant_pdf_system_url': config['participant_pdf_system_url'], + 'participant_pdf_welcometext': config['participant_pdf_welcometext'], + } + + def form_valid(self, form): + config['participant_pdf_system_url'] = form.cleaned_data['participant_pdf_system_url'] + config['participant_pdf_welcometext'] = form.cleaned_data['participant_pdf_welcometext'] + messages.success(self.request, _('Participants settings successfully saved.')) + return super(Config, self).form_valid(form) \ No newline at end of file diff --git a/openslides/static/styles/base.css b/openslides/static/styles/base.css index 9fddd29d9..ee987bf86 100644 --- a/openslides/static/styles/base.css +++ b/openslides/static/styles/base.css @@ -456,6 +456,12 @@ form input:after { font-weight: bold; } +/* Fieldsets */ +fieldset { + width: 0px; + padding: 0 60px 0 20px; +} + /* Lists */ ul { list-style:none outside none; diff --git a/openslides/utils/pdf.py b/openslides/utils/pdf.py index 887cd2967..a48cf7e7b 100755 --- a/openslides/utils/pdf.py +++ b/openslides/utils/pdf.py @@ -261,8 +261,8 @@ def print_passwords(request): story = [Spacer(0,0*cm)] data= [] - system_url = config["system_url"] - system_welcometext = config["system_welcometext"] + participant_pdf_system_url = config["participant_pdf_system_url"] + participant_pdf_welcometext = config["participant_pdf_welcometext"] for user in User.objects.all().order_by('last_name'): try: user.get_profile() @@ -274,12 +274,12 @@ def print_passwords(request): cell.append(Paragraph(_("User: %s") % (user.username), stylesheet['Ballot_option'])) cell.append(Paragraph(_("Password: %s") % (user.profile.firstpassword), stylesheet['Ballot_option'])) cell.append(Spacer(0,0.5*cm)) - cell.append(Paragraph(_("URL: %s") % (system_url), stylesheet['Ballot_option'])) + cell.append(Paragraph(_("URL: %s") % (participant_pdf_system_url), stylesheet['Ballot_option'])) cell.append(Spacer(0,0.5*cm)) cell2 = [] cell2.append(Spacer(0,0.8*cm)) - if system_welcometext is not None: - cell2.append(Paragraph(system_welcometext.replace('\r\n','
'), stylesheet['Ballot_subtitle'])) + if participant_pdf_welcometext is not None: + cell2.append(Paragraph(participant_pdf_welcometext.replace('\r\n','
'), stylesheet['Ballot_subtitle'])) data.append([cell,cell2]) except Profile.DoesNotExist: