diff --git a/openslides/assignment/templates/assignment/base_assignment.html b/openslides/assignment/templates/assignment/base_assignment.html
index edb530f4f..992896d05 100644
--- a/openslides/assignment/templates/assignment/base_assignment.html
+++ b/openslides/assignment/templates/assignment/base_assignment.html
@@ -14,5 +14,6 @@
{% if perms.assignment.can_manage_assignment %}
{%trans "New election" %}
{% endif %}
+ {%trans 'Print all elections' %}
{% endblock %}
diff --git a/openslides/assignment/templates/assignment/view.html b/openslides/assignment/templates/assignment/view.html
index c1dc8cd34..905c7e803 100644
--- a/openslides/assignment/templates/assignment/view.html
+++ b/openslides/assignment/templates/assignment/view.html
@@ -6,8 +6,11 @@
{% trans "Status" %}:
+
+
+
+
{% trans assignment.get_status_display %}
-
{% trans "Number of available posts" %}:
{{ assignment.posts }}
diff --git a/openslides/assignment/urls.py b/openslides/assignment/urls.py
index 80815b3be..0edffe2ad 100644
--- a/openslides/assignment/urls.py
+++ b/openslides/assignment/urls.py
@@ -43,6 +43,12 @@ urlpatterns = patterns('assignment.views',
url(r'^assignment/poll/(?P\d+)/print$', 'print_assignment_poll', \
name='print_assignment_poll'),
+ url(r'^assignment/print$', 'print_assignment', \
+ name='print_assignment'),
+
+ url(r'^assignment/(?P\d+)/print$', 'print_assignment', \
+ name='print_assignment'),
+
url(r'^assignment/(?P\d+)/gen_poll$', 'gen_poll', \
name='assignment_gen_poll'),
diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py
index 99ea68d0f..111b50cc7 100644
--- a/openslides/assignment/views.py
+++ b/openslides/assignment/views.py
@@ -21,7 +21,7 @@ from poll.forms import OptionResultForm, PollForm
from assignment.models import Assignment
from assignment.forms import AssignmentForm, AssignmentRunForm
from utils.utils import template, permission_required, gen_confirm_form, del_confirm_form, ajax_request
-from utils.pdf import print_assignment_poll
+from utils.pdf import print_assignment, print_assignment_poll
from participant.models import Profile
diff --git a/openslides/utils/pdf.py b/openslides/utils/pdf.py
index dca79b5ff..b0d2e6bfd 100755
--- a/openslides/utils/pdf.py
+++ b/openslides/utils/pdf.py
@@ -33,8 +33,9 @@ from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from openslides.agenda.models import Item
-from openslides.application.models import Application
from openslides.agenda.api import children_list
+from openslides.application.models import Application
+from openslides.assignment.models import Assignment
from openslides.poll.models import Poll
from openslides.participant.models import Profile
from openslides.system.api import config_get
@@ -420,6 +421,7 @@ def print_application(request, application_id=None):
if application_id is None: #print all applications
story.append(Paragraph(_("Applications"), stylesheet['Heading1']))
+ story.append(Spacer(0,0.75*cm))
# List of applications
for application in Application.objects.exclude(number=None).order_by('number'):
story.append(Paragraph(_("Application No.")+" %s: %s" % (application.number, application.title), stylesheet['Heading3']))
@@ -469,7 +471,69 @@ def print_application_poll(request, poll_id=None):
doc.build(story)
return response
+def get_assignment(assignment, story):
+ # title
+ story.append(Paragraph(_("Election")+": %s" % assignment.name, stylesheet['Heading1']))
+ story.append(Spacer(0,0.5*cm))
+ # posts
+ cell1a = []
+ cell1a.append(Paragraph("%s:" % _("Number of available posts"), stylesheet['Bold']))
+ cell1b = []
+ cell1b.append(Paragraph(str(assignment.posts), stylesheet['Paragraph']))
+ # candidates
+ cell2a = []
+ cell2a.append(Paragraph("%s:" % _("Candidates"), stylesheet['Heading4']))
+ cell2b = []
+ for c in assignment.candidates:
+ cell2b.append(Paragraph(". %s" % unicode(c), stylesheet['Signaturefield']))
+ if assignment.status == "sea":
+ for x in range(0,2*assignment.posts):
+ cell2b.append(Paragraph(". __________________________________________",stylesheet['Signaturefield']))
+ cell2b.append(Spacer(0,0.2*cm))
+ # table
+ data = []
+ data.append([cell1a,cell1b])
+ data.append([cell2a,cell2b])
+ t=Table(data)
+ t._argW[0]=4.5*cm
+ t._argW[1]=11*cm
+ t.setStyle(TableStyle([ ('BOX', (0,0), (-1,-1), 1, colors.black),
+ ('VALIGN', (0,0), (-1,-1), 'TOP'),
+ ]))
+ story.append(t)
+ story.append(Spacer(0,1*cm))
+ # text
+ story.append(Paragraph("%s" % assignment.description.replace('\r\n','
'), stylesheet['Paragraph']))
+ return story
+
+@permission_required('application.can_see_application')
+def print_assignment(request, assignment_id=None):
+ response = HttpResponse(mimetype='application/pdf')
+ filename = u'filename=%s.pdf;' % _("Elections")
+ response['Content-Disposition'] = filename.encode('utf-8')
+ doc = SimpleDocTemplate(response)
+ doc.title = None
+ story = []
+
+ if assignment_id is None: #print all applications
+ story.append(Paragraph(_("Elections"), stylesheet['Heading1']))
+ story.append(Spacer(0,0.75*cm))
+ # List of assignments
+ for assignment in Assignment.objects.order_by('name'):
+ story.append(Paragraph(assignment.name, stylesheet['Heading3']))
+ # Assignment details (each assignment on single page)
+ for assignment in Assignment.objects.order_by('name'):
+ story.append(PageBreak())
+ story = get_assignment(assignment, story)
+ else: # print selected assignment
+ assignment = Assignment.objects.get(id=assignment_id)
+ filename = u'filename=%s-%s.pdf;' % (_("Assignment"), assignment.name.replace(' ','_'))
+ response['Content-Disposition'] = filename.encode('utf-8')
+ story = get_assignment(assignment, story)
+ doc.build(story, onFirstPage=firstPage, onLaterPages=firstPage)
+ return response
+
@permission_required('application.can_manage_application')
def print_assignment_poll(request, poll_id=None):
poll = Poll.objects.get(id=poll_id)