#26: Added new config options to set numbers of ballot pdf papers for application and assignment
This commit is contained in:
parent
e0ce55daa7
commit
b6ccb357d1
@ -10,7 +10,7 @@
|
|||||||
:license: GNU GPL, see LICENSE for more details.
|
:license: GNU GPL, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.forms import Form, CharField, TextInput, BooleanField, IntegerField, Textarea
|
from django.forms import Form, CharField, TextInput, BooleanField, IntegerField, ChoiceField, Textarea, Select
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from system.api import config_get
|
from system.api import config_get
|
||||||
|
|
||||||
@ -38,6 +38,8 @@ 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_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_preamble = CharField(widget=TextInput(), required=False, label=_("Application preamble"))
|
||||||
|
application_pdf_ballot_papers_selection = ChoiceField(widget=Select(), required=False, label=_("Number of ballot papers (selection)"), choices=[("1", _("Number of all delegates")),("2", "Number of all participants"),("0", "Use the following custum number")])
|
||||||
|
application_pdf_ballot_papers_number = IntegerField(widget=TextInput(attrs={'class':'small-input'}), required=False, min_value=1, label=_("Custom number of ballot papers"))
|
||||||
application_pdf_title = CharField(widget=TextInput(), required=False, label=_("Title for PDF document (all applications)"))
|
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)"))
|
application_pdf_preamble = CharField(widget=Textarea(), required=False, label=_("Preamble text for PDF document (all applications)"))
|
||||||
|
|
||||||
@ -47,5 +49,7 @@ class AssignmentConfigForm(Form):
|
|||||||
|
|
||||||
assignment_pdf_title = CharField(widget=TextInput(), required=False, label=_("Title for PDF document (all elections)"))
|
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)"))
|
assignment_pdf_preamble = CharField(widget=Textarea(), required=False, label=_("Preamble text for PDF document (all elections)"))
|
||||||
|
assignment_pdf_ballot_papers_selection = ChoiceField(widget=Select(), required=False, label=_("Number of ballot papers (selection)"), choices=[("1", _("Number of all delegates")),("2", "Number of all participants"),("0", "Use the following custum number")])
|
||||||
|
assignment_pdf_ballot_papers_number = IntegerField(widget=TextInput(attrs={'class':'small-input'}), required=False, min_value=1, label=_("Custom number of ballot papers"))
|
||||||
|
|
||||||
|
|
@ -48,15 +48,22 @@ def get_general_config(request):
|
|||||||
form_application = ApplicationConfigForm(request.POST, prefix='application')
|
form_application = ApplicationConfigForm(request.POST, prefix='application')
|
||||||
form_assignment = AssignmentConfigForm(request.POST, prefix='assignment')
|
form_assignment = AssignmentConfigForm(request.POST, prefix='assignment')
|
||||||
if form_event.is_valid() and form_application.is_valid() and form_assignment.is_valid():
|
if form_event.is_valid() and form_application.is_valid() and form_assignment.is_valid():
|
||||||
|
# event form
|
||||||
config_set('event_name', form_event.cleaned_data['event_name'])
|
config_set('event_name', form_event.cleaned_data['event_name'])
|
||||||
config_set('event_description', form_event.cleaned_data['event_description'])
|
config_set('event_description', form_event.cleaned_data['event_description'])
|
||||||
config_set('event_date', form_event.cleaned_data['event_date'])
|
config_set('event_date', form_event.cleaned_data['event_date'])
|
||||||
config_set('event_location', form_event.cleaned_data['event_location'])
|
config_set('event_location', form_event.cleaned_data['event_location'])
|
||||||
config_set('event_organizer', form_event.cleaned_data['event_organizer'])
|
config_set('event_organizer', form_event.cleaned_data['event_organizer'])
|
||||||
|
# application form
|
||||||
config_set('application_min_supporters', form_application.cleaned_data['application_min_supporters'])
|
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_preamble', form_application.cleaned_data['application_preamble'])
|
||||||
|
config_set('application_pdf_ballot_papers_selection', form_application.cleaned_data['application_pdf_ballot_papers_selection'])
|
||||||
|
config_set('application_pdf_ballot_papers_number', form_application.cleaned_data['application_pdf_ballot_papers_number'])
|
||||||
config_set('application_pdf_title', form_application.cleaned_data['application_pdf_title'])
|
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('application_pdf_preamble', form_application.cleaned_data['application_pdf_preamble'])
|
||||||
|
# assignment form
|
||||||
|
config_set('assignment_pdf_ballot_papers_selection', form_assignment.cleaned_data['assignment_pdf_ballot_papers_selection'])
|
||||||
|
config_set('assignment_pdf_ballot_papers_number', form_assignment.cleaned_data['assignment_pdf_ballot_papers_number'])
|
||||||
config_set('assignment_pdf_title', form_assignment.cleaned_data['assignment_pdf_title'])
|
config_set('assignment_pdf_title', form_assignment.cleaned_data['assignment_pdf_title'])
|
||||||
config_set('assignment_pdf_preamble', form_assignment.cleaned_data['assignment_pdf_preamble'])
|
config_set('assignment_pdf_preamble', form_assignment.cleaned_data['assignment_pdf_preamble'])
|
||||||
messages.success(request, _('General settings successfully saved.'))
|
messages.success(request, _('General settings successfully saved.'))
|
||||||
@ -74,10 +81,14 @@ def get_general_config(request):
|
|||||||
form_application = ApplicationConfigForm(initial={
|
form_application = ApplicationConfigForm(initial={
|
||||||
'application_min_supporters': config_get('application_min_supporters'),
|
'application_min_supporters': config_get('application_min_supporters'),
|
||||||
'application_preamble': config_get('application_preamble'),
|
'application_preamble': config_get('application_preamble'),
|
||||||
|
'application_pdf_ballot_papers_selection': config_get('application_pdf_ballot_papers_selection'),
|
||||||
|
'application_pdf_ballot_papers_number': config_get('application_pdf_ballot_papers_number'),
|
||||||
'application_pdf_title': config_get('application_pdf_title'),
|
'application_pdf_title': config_get('application_pdf_title'),
|
||||||
'application_pdf_preamble': config_get('application_pdf_preamble'),
|
'application_pdf_preamble': config_get('application_pdf_preamble'),
|
||||||
}, prefix='application')
|
}, prefix='application')
|
||||||
form_assignment = AssignmentConfigForm(initial={
|
form_assignment = AssignmentConfigForm(initial={
|
||||||
|
'assignment_pdf_ballot_papers_selection': config_get('assignment_pdf_ballot_papers_selection'),
|
||||||
|
'assignment_pdf_ballot_papers_number': config_get('assignment_pdf_ballot_papers_number'),
|
||||||
'assignment_pdf_title': config_get('assignment_pdf_title'),
|
'assignment_pdf_title': config_get('assignment_pdf_title'),
|
||||||
'assignment_pdf_preamble': config_get('assignment_pdf_preamble'),
|
'assignment_pdf_preamble': config_get('assignment_pdf_preamble'),
|
||||||
}, prefix='assignment')
|
}, prefix='assignment')
|
||||||
|
@ -484,8 +484,23 @@ def print_application_poll(request, poll_id=None):
|
|||||||
cell.append(Paragraph(circle+_("Abstention"), stylesheet['Ballot_option']))
|
cell.append(Paragraph(circle+_("Abstention"), stylesheet['Ballot_option']))
|
||||||
|
|
||||||
data= []
|
data= []
|
||||||
for user in xrange(User.objects.count()/2):
|
number = 1
|
||||||
|
# get ballot papers config values
|
||||||
|
ballot_papers_selection = config_get("application_pdf_ballot_papers_selection")
|
||||||
|
ballot_papers_number = config_get("application_pdf_ballot_papers_number")
|
||||||
|
# set number of ballot papers
|
||||||
|
if ballot_papers_selection == "1":
|
||||||
|
number = User.objects.filter(profile__type__iexact="delegate").count()
|
||||||
|
if ballot_papers_selection == "2":
|
||||||
|
number = int(User.objects.count() - 1)
|
||||||
|
if ballot_papers_selection == "0":
|
||||||
|
number = int(ballot_papers_number)
|
||||||
|
# print ballot papers
|
||||||
|
for user in xrange(number/2):
|
||||||
data.append([cell,cell])
|
data.append([cell,cell])
|
||||||
|
rest = number % 2
|
||||||
|
if rest:
|
||||||
|
data.append([cell,''])
|
||||||
t=Table(data, 10.5*cm, 7.42*cm)
|
t=Table(data, 10.5*cm, 7.42*cm)
|
||||||
t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey),
|
t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey),
|
||||||
('VALIGN', (0,0), (-1,-1), 'TOP'),
|
('VALIGN', (0,0), (-1,-1), 'TOP'),
|
||||||
@ -670,6 +685,11 @@ def print_assignment_poll(request, poll_id=None):
|
|||||||
cell.append(Paragraph(str(poll.ballot)+". "+_("ballot")+", "+str(len(options))+" "+ ungettext("candidate", "candidates", len(options))+", "+str(poll.assignment.posts)+" "+_("available posts"), stylesheet['Ballot_description']))
|
cell.append(Paragraph(str(poll.ballot)+". "+_("ballot")+", "+str(len(options))+" "+ ungettext("candidate", "candidates", len(options))+", "+str(poll.assignment.posts)+" "+_("available posts"), stylesheet['Ballot_description']))
|
||||||
cell.append(Spacer(0,0.4*cm))
|
cell.append(Spacer(0,0.4*cm))
|
||||||
|
|
||||||
|
data= []
|
||||||
|
# get ballot papers config values
|
||||||
|
number = 1
|
||||||
|
ballot_papers_selection = config_get("assignment_pdf_ballot_papers_selection")
|
||||||
|
ballot_papers_number = config_get("assignment_pdf_ballot_papers_number")
|
||||||
if poll.optiondecision:
|
if poll.optiondecision:
|
||||||
for option in options:
|
for option in options:
|
||||||
o = str(option).split("(",1)
|
o = str(option).split("(",1)
|
||||||
@ -679,9 +699,20 @@ def print_assignment_poll(request, poll_id=None):
|
|||||||
else:
|
else:
|
||||||
cell.append(Paragraph(" ", stylesheet['Ballot_option_group']))
|
cell.append(Paragraph(" ", stylesheet['Ballot_option_group']))
|
||||||
cell.append(Paragraph(circle+_("Yes")+" "+circle+_("No")+" "+circle+_("Abstention"), stylesheet['Ballot_option_YNA']))
|
cell.append(Paragraph(circle+_("Yes")+" "+circle+_("No")+" "+circle+_("Abstention"), stylesheet['Ballot_option_YNA']))
|
||||||
data= []
|
# set number of ballot papers
|
||||||
for user in xrange(User.objects.count()/2):
|
if ballot_papers_selection == "1":
|
||||||
|
number = User.objects.filter(profile__type__iexact="delegate").count()
|
||||||
|
if ballot_papers_selection == "2":
|
||||||
|
number = int(User.objects.count() - 1)
|
||||||
|
if ballot_papers_selection == "0":
|
||||||
|
number = int(ballot_papers_number)
|
||||||
|
# print ballot papers
|
||||||
|
for user in xrange(number/2):
|
||||||
data.append([cell,cell])
|
data.append([cell,cell])
|
||||||
|
rest = number % 2
|
||||||
|
if rest:
|
||||||
|
data.append([cell,''])
|
||||||
|
|
||||||
if len(options) <= 2:
|
if len(options) <= 2:
|
||||||
t=Table(data, 10.5*cm, 7.42*cm)
|
t=Table(data, 10.5*cm, 7.42*cm)
|
||||||
elif len(options) <= 5:
|
elif len(options) <= 5:
|
||||||
@ -696,9 +727,20 @@ def print_assignment_poll(request, poll_id=None):
|
|||||||
cell.append(Paragraph("("+o[1], stylesheet['Ballot_option_group_right']))
|
cell.append(Paragraph("("+o[1], stylesheet['Ballot_option_group_right']))
|
||||||
else:
|
else:
|
||||||
cell.append(Paragraph(" ", stylesheet['Ballot_option_group_right']))
|
cell.append(Paragraph(" ", stylesheet['Ballot_option_group_right']))
|
||||||
data= []
|
# set number of ballot papers
|
||||||
for user in xrange(User.objects.count()/2):
|
if ballot_papers_selection == "1":
|
||||||
|
number = User.objects.filter(profile__type__iexact="delegate").count()
|
||||||
|
if ballot_papers_selection == "2":
|
||||||
|
number = int(User.objects.count() - 1)
|
||||||
|
if ballot_papers_selection == "0":
|
||||||
|
number = int(ballot_papers_number)
|
||||||
|
# print ballot papers
|
||||||
|
for user in xrange(number/2):
|
||||||
data.append([cell,cell])
|
data.append([cell,cell])
|
||||||
|
rest = number % 2
|
||||||
|
if rest:
|
||||||
|
data.append([cell,''])
|
||||||
|
|
||||||
if len(options) <= 4:
|
if len(options) <= 4:
|
||||||
t=Table(data, 10.5*cm, 7.42*cm)
|
t=Table(data, 10.5*cm, 7.42*cm)
|
||||||
elif len(options) <= 8:
|
elif len(options) <= 8:
|
||||||
|
Loading…
Reference in New Issue
Block a user