New config option to set title and preamble text for application and assignment pdf.
This commit is contained in:
parent
e08455d6ea
commit
fa5918e951
@ -22,7 +22,6 @@ class SystemConfigForm(Form):
|
||||
system_url = CharField(widget=TextInput(), required=False, label=_("System URL"))
|
||||
system_welcometext = CharField(widget=Textarea(), required=False, label=_("Welcome text (for password PDF)"))
|
||||
|
||||
|
||||
class EventConfigForm(Form):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
@ -39,6 +38,14 @@ class ApplicationConfigForm(Form):
|
||||
|
||||
application_min_supporters = IntegerField(widget=TextInput(attrs={'class':'small-input'}),label=_("Number of (minimum) required supporters for a application"),initial=4, min_value=0, max_value=8)
|
||||
application_preamble = CharField(widget=TextInput(), required=False, label=_("Application preamble"))
|
||||
application_pdf_title = CharField(widget=TextInput(), required=False, label=_("Title for PDF document (all applications)"))
|
||||
application_pdf_preamble = CharField(widget=Textarea(), required=False, label=_("Preamble text for PDF document (all applications)"))
|
||||
|
||||
class AssignmentConfigForm(Form):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
||||
assignment_pdf_title = CharField(widget=TextInput(), required=False, label=_("Title for PDF document (all elections)"))
|
||||
assignment_pdf_preamble = CharField(widget=Textarea(), required=False, label=_("Preamble text for PDF document (all elections)"))
|
||||
|
||||
|
@ -11,13 +11,16 @@
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
DEFAULT_DATA = {
|
||||
'event_name': 'OpenSlides',
|
||||
'event_description': 'Presentation and voting system',
|
||||
'application_min_supporters': 4,
|
||||
'application_preamble': 'Die Versammlung möge beschließen,',
|
||||
'sysem_url': 'http://openslides:8000',
|
||||
'application_pdf_title': _('Applications'),
|
||||
'assignment_pdf_title': _('Elections'),
|
||||
'system_url': 'http://127.0.0.1:8000',
|
||||
}
|
||||
|
||||
class Config(models.Model):
|
||||
|
@ -13,7 +13,11 @@
|
||||
<legend>{%trans "Application" %}</legend>
|
||||
{{ form_application.as_p }}
|
||||
</fieldset>
|
||||
|
||||
<p></p>
|
||||
<fieldset>
|
||||
<legend>{%trans "Elections" %}</legend>
|
||||
{{ form_assignment.as_p }}
|
||||
</fieldset>
|
||||
<p>
|
||||
<button type="submit">
|
||||
<span class="icon ok">{%trans 'Save' %}</span>
|
||||
|
@ -16,7 +16,7 @@ from django.contrib import messages
|
||||
from django.utils.translation import ugettext as _
|
||||
from utils.utils import template
|
||||
from utils.utils import template, permission_required
|
||||
from system.forms import SystemConfigForm, EventConfigForm, ApplicationConfigForm
|
||||
from system.forms import SystemConfigForm, EventConfigForm, ApplicationConfigForm, AssignmentConfigForm
|
||||
from system.api import config_get, config_set
|
||||
|
||||
@permission_required('system.can_manage_system')
|
||||
@ -46,7 +46,8 @@ def get_general_config(request):
|
||||
if request.method == 'POST':
|
||||
form_event = EventConfigForm(request.POST, prefix='event')
|
||||
form_application = ApplicationConfigForm(request.POST, prefix='application')
|
||||
if form_event.is_valid() and form_application.is_valid():
|
||||
form_assignment = AssignmentConfigForm(request.POST, prefix='assignment')
|
||||
if form_event.is_valid() and form_application.is_valid() and form_assignment.is_valid():
|
||||
config_set('event_name', form_event.cleaned_data['event_name'])
|
||||
config_set('event_description', form_event.cleaned_data['event_description'])
|
||||
config_set('event_date', form_event.cleaned_data['event_date'])
|
||||
@ -54,6 +55,10 @@ def get_general_config(request):
|
||||
config_set('event_organizer', form_event.cleaned_data['event_organizer'])
|
||||
config_set('application_min_supporters', form_application.cleaned_data['application_min_supporters'])
|
||||
config_set('application_preamble', form_application.cleaned_data['application_preamble'])
|
||||
config_set('application_pdf_title', form_application.cleaned_data['application_pdf_title'])
|
||||
config_set('application_pdf_preamble', form_application.cleaned_data['application_pdf_preamble'])
|
||||
config_set('assignment_pdf_title', form_assignment.cleaned_data['assignment_pdf_title'])
|
||||
config_set('assignment_pdf_preamble', form_assignment.cleaned_data['assignment_pdf_preamble'])
|
||||
messages.success(request, _('General settings successfully saved.'))
|
||||
else:
|
||||
messages.error(request, _('Please check the form for errors.'))
|
||||
@ -69,8 +74,15 @@ def get_general_config(request):
|
||||
form_application = ApplicationConfigForm(initial={
|
||||
'application_min_supporters': config_get('application_min_supporters'),
|
||||
'application_preamble': config_get('application_preamble'),
|
||||
'application_pdf_title': config_get('application_pdf_title'),
|
||||
'application_pdf_preamble': config_get('application_pdf_preamble'),
|
||||
}, prefix='application')
|
||||
form_assignment = AssignmentConfigForm(initial={
|
||||
'assignment_pdf_title': config_get('assignment_pdf_title'),
|
||||
'assignment_pdf_preamble': config_get('assignment_pdf_preamble'),
|
||||
}, prefix='assignment')
|
||||
return {
|
||||
'form_event': form_event,
|
||||
'form_application': form_application,
|
||||
'form_assignment': form_assignment,
|
||||
}
|
||||
|
@ -433,7 +433,10 @@ def print_application(request, application_id=None):
|
||||
story = []
|
||||
|
||||
if application_id is None: #print all applications
|
||||
story.append(Paragraph(_("Applications"), stylesheet['Heading1']))
|
||||
title = config_get("application_pdf_title")
|
||||
story.append(Paragraph(title, stylesheet['Heading1']))
|
||||
preamble = config_get("application_pdf_preamble")
|
||||
story.append(Paragraph("%s" % preamble.replace('\r\n','<br/>'), stylesheet['Paragraph']))
|
||||
story.append(Spacer(0,0.75*cm))
|
||||
# List of applications
|
||||
for application in Application.objects.order_by('number'):
|
||||
@ -624,7 +627,10 @@ def print_assignment(request, assignment_id=None):
|
||||
story = []
|
||||
|
||||
if assignment_id is None: #print all applications
|
||||
story.append(Paragraph(_("Elections"), stylesheet['Heading1']))
|
||||
title = config_get("assignment_pdf_title")
|
||||
story.append(Paragraph(title, stylesheet['Heading1']))
|
||||
preamble = config_get("assignment_pdf_preamble")
|
||||
story.append(Paragraph("%s" % preamble.replace('\r\n','<br/>'), stylesheet['Paragraph']))
|
||||
story.append(Spacer(0,0.75*cm))
|
||||
# List of assignments
|
||||
for assignment in Assignment.objects.order_by('name'):
|
||||
|
Loading…
Reference in New Issue
Block a user