2011-07-31 10:46:29 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
openslides.utils.pdf
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Print PDF functions for all OpenSlides apps.
|
|
|
|
|
|
|
|
:copyright: 2011 by the OpenSlides team, see AUTHORS.
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from datetime import datetime
|
2011-09-04 08:23:03 +02:00
|
|
|
import os
|
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
from django.http import HttpResponse, HttpResponseNotFound
|
|
|
|
from django.shortcuts import render_to_response
|
|
|
|
from django.template import RequestContext
|
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from django.utils.translation import ungettext
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
|
|
from reportlab.pdfgen.canvas import Canvas
|
|
|
|
from reportlab.lib import colors
|
|
|
|
from reportlab.lib.pagesizes import A4
|
2011-09-02 15:54:13 +02:00
|
|
|
from reportlab.lib.units import cm
|
2011-07-31 10:46:29 +02:00
|
|
|
from reportlab.lib.styles import ParagraphStyle as PS
|
2011-09-02 15:54:13 +02:00
|
|
|
from reportlab.lib.styles import StyleSheet1, ParagraphStyle
|
2011-07-31 10:46:29 +02:00
|
|
|
from reportlab.platypus import SimpleDocTemplate, Paragraph, Frame, PageBreak, Spacer, Table, LongTable, TableStyle, Image
|
|
|
|
from reportlab.platypus.doctemplate import SimpleDocTemplate
|
|
|
|
from reportlab.rl_config import defaultPageSize
|
|
|
|
from reportlab.pdfbase import pdfmetrics
|
|
|
|
from reportlab.pdfbase.ttfonts import TTFont
|
|
|
|
|
|
|
|
from openslides.agenda.models import Item
|
|
|
|
from openslides.agenda.api import children_list
|
2011-09-07 07:52:44 +02:00
|
|
|
from openslides.application.models import Application
|
|
|
|
from openslides.assignment.models import Assignment
|
2011-09-09 16:18:11 +02:00
|
|
|
from openslides.poll.models import Poll, Option
|
2011-07-31 10:46:29 +02:00
|
|
|
from openslides.participant.models import Profile
|
|
|
|
from openslides.system.api import config_get
|
2011-09-04 08:23:03 +02:00
|
|
|
from openslides.settings import SITE_ROOT
|
2011-09-04 09:34:52 +02:00
|
|
|
from openslides.utils.utils import permission_required
|
2011-07-31 10:46:29 +02:00
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
# register new truetype fonts
|
2011-09-04 08:23:03 +02:00
|
|
|
pdfmetrics.registerFont(TTFont('Ubuntu', os.path.join(SITE_ROOT, 'static/fonts/Ubuntu-R.ttf')))
|
|
|
|
pdfmetrics.registerFont(TTFont('Ubuntu-Bold', os.path.join(SITE_ROOT, 'static/fonts/Ubuntu-B.ttf')))
|
|
|
|
pdfmetrics.registerFont(TTFont('Ubuntu-Italic', os.path.join(SITE_ROOT, 'static/fonts/Ubuntu-RI.ttf')))
|
2011-07-31 10:46:29 +02:00
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
# set style information
|
|
|
|
PAGE_HEIGHT=defaultPageSize[1];
|
|
|
|
PAGE_WIDTH=defaultPageSize[0]
|
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-09-02 15:54:13 +02:00
|
|
|
# set custom stylesheets
|
|
|
|
stylesheet = StyleSheet1()
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Normal',
|
|
|
|
fontName = 'Ubuntu',
|
|
|
|
fontSize = 10,
|
|
|
|
leading = 12)
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Paragraph',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
leading = 14,
|
|
|
|
spaceAfter = 15)
|
|
|
|
)
|
2011-09-06 23:01:21 +02:00
|
|
|
stylesheet.add(ParagraphStyle(name = 'Small',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 8)
|
|
|
|
)
|
2011-09-02 15:54:13 +02:00
|
|
|
stylesheet.add(ParagraphStyle(name = 'Italic',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontName = 'Ubuntu-Italic',
|
|
|
|
spaceAfter = 5)
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Bold',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontName = 'Ubuntu-Bold')
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Heading1',
|
|
|
|
parent = stylesheet['Bold'],
|
2011-09-02 16:34:12 +02:00
|
|
|
fontSize = 24,
|
|
|
|
leading = 30,
|
2011-09-02 15:54:13 +02:00
|
|
|
spaceAfter = 6),
|
|
|
|
alias = 'h1')
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Heading2',
|
|
|
|
parent = stylesheet['Bold'],
|
|
|
|
fontSize = 14,
|
|
|
|
leading = 24,
|
|
|
|
spaceAfter = 10),
|
|
|
|
alias = 'h2')
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Heading3',
|
|
|
|
parent = stylesheet['Bold'],
|
|
|
|
fontSize = 12,
|
2011-09-06 22:22:29 +02:00
|
|
|
leading = 20),
|
2011-09-02 15:54:13 +02:00
|
|
|
alias = 'h3')
|
2011-09-06 22:22:29 +02:00
|
|
|
stylesheet.add(ParagraphStyle(name = 'Heading4',
|
|
|
|
parent = stylesheet['Bold'],
|
|
|
|
fontSize = 10,
|
|
|
|
leading = 20),
|
|
|
|
)
|
2011-09-02 15:54:13 +02:00
|
|
|
stylesheet.add(ParagraphStyle(name = 'Item',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 14,
|
2011-09-11 17:06:32 +02:00
|
|
|
leading = 14,
|
2011-09-02 15:54:13 +02:00
|
|
|
leftIndent = 0,
|
|
|
|
spaceAfter = 15)
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Subitem',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 10,
|
2011-09-11 17:06:32 +02:00
|
|
|
leading = 10,
|
2011-09-02 15:54:13 +02:00
|
|
|
leftIndent = 20,
|
|
|
|
spaceAfter = 15)
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Tablecell',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 9)
|
|
|
|
)
|
2011-09-06 22:22:29 +02:00
|
|
|
stylesheet.add(ParagraphStyle(name = 'Signaturefield',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
spaceBefore = 15)
|
|
|
|
)
|
|
|
|
|
2011-09-02 17:39:32 +02:00
|
|
|
# Ballot stylesheets
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Ballot_title',
|
|
|
|
parent = stylesheet['Bold'],
|
|
|
|
fontSize = 12,
|
|
|
|
leading = 14,
|
|
|
|
leftIndent = 30),
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Ballot_subtitle',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 10,
|
2011-09-03 23:38:14 +02:00
|
|
|
leading = 12,
|
2011-09-02 17:39:32 +02:00
|
|
|
leftIndent = 30,
|
2011-09-03 23:38:14 +02:00
|
|
|
rightIndent = 20,
|
|
|
|
spaceAfter = 5),
|
2011-09-02 17:39:32 +02:00
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Ballot_description',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 7,
|
2011-09-03 23:38:14 +02:00
|
|
|
leading = 10,
|
2011-09-02 17:39:32 +02:00
|
|
|
leftIndent = 30),
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Ballot_option',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 12,
|
|
|
|
leading = 24,
|
|
|
|
leftIndent = 30),
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Ballot_option_name',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 12,
|
|
|
|
leading = 15,
|
|
|
|
leftIndent = 30),
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Ballot_option_group',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 8,
|
|
|
|
leading = 15,
|
|
|
|
leftIndent = 30),
|
|
|
|
)
|
|
|
|
stylesheet.add(ParagraphStyle(name = 'Ballot_option_YNA',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 12,
|
|
|
|
leading = 15,
|
|
|
|
leftIndent = 49,
|
|
|
|
spaceAfter = 18),
|
2011-09-05 09:14:38 +02:00
|
|
|
)
|
2011-09-02 17:39:32 +02:00
|
|
|
stylesheet.add(ParagraphStyle(name = 'Ballot_option_group_right',
|
|
|
|
parent = stylesheet['Normal'],
|
|
|
|
fontSize = 8,
|
|
|
|
leading = 16,
|
|
|
|
leftIndent = 49),
|
|
|
|
)
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
# set event information
|
|
|
|
event_name = config_get("event_name")
|
|
|
|
event_description = config_get("event_description")
|
|
|
|
event_date = config_get("event_date")
|
|
|
|
event_location = config_get("event_location")
|
|
|
|
event_organizer = config_get("event_organizer")
|
|
|
|
|
|
|
|
# set print time
|
2011-09-08 09:37:19 +02:00
|
|
|
time = datetime.now().strftime(str(_("%Y-%m-%d %H:%Mh")))
|
2011-07-31 10:46:29 +02:00
|
|
|
|
2011-09-02 15:54:13 +02:00
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
def firstPage(canvas, doc):
|
|
|
|
canvas.saveState()
|
|
|
|
# page header (with event information)
|
|
|
|
canvas.setFont('Ubuntu',10)
|
|
|
|
canvas.setFillGray(0.4)
|
|
|
|
canvas.drawString(2.75*cm, 28*cm, "%s | %s" % (event_name, event_description))
|
2011-09-04 08:39:36 +02:00
|
|
|
if event_date and event_location:
|
2011-07-31 10:46:29 +02:00
|
|
|
canvas.drawString(2.75*cm, 27.6*cm, "%s, %s" % (event_date, event_location))
|
|
|
|
# time
|
|
|
|
canvas.setFont('Ubuntu',7)
|
|
|
|
canvas.drawString(15*cm, 28*cm, _("Printed")+": %s" % time)
|
|
|
|
# title
|
2011-09-02 16:34:12 +02:00
|
|
|
if doc.title:
|
|
|
|
canvas.setFont('Ubuntu-Bold',24)
|
|
|
|
canvas.setFillGray(0)
|
|
|
|
#canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT-108, doc.title)
|
|
|
|
canvas.drawString(2.75*cm, PAGE_HEIGHT-108, doc.title)
|
2011-07-31 10:46:29 +02:00
|
|
|
# footer (with page number)
|
|
|
|
canvas.setFont('Ubuntu',8)
|
|
|
|
canvas.setFillGray(0.4)
|
2011-09-06 22:22:29 +02:00
|
|
|
canvas.drawString(10*cm, 1*cm, _("Page")+" %s" % doc.page)
|
2011-07-31 10:46:29 +02:00
|
|
|
canvas.restoreState()
|
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
def laterPages(canvas, doc):
|
|
|
|
canvas.saveState()
|
|
|
|
# footer (with page number)
|
|
|
|
canvas.setFont('Ubuntu',7)
|
|
|
|
canvas.setFillGray(0.4)
|
|
|
|
canvas.drawString(10*cm, 1*cm, _("Page")+" %s" % doc.page)
|
|
|
|
canvas.restoreState()
|
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-09-04 12:21:58 +02:00
|
|
|
@permission_required('agenda.can_see_agenda')
|
2011-09-03 01:24:50 +02:00
|
|
|
def print_agenda(request):
|
2011-07-31 10:46:29 +02:00
|
|
|
response = HttpResponse(mimetype='application/pdf')
|
|
|
|
filename = u'filename=%s.pdf;' % _("Agenda")
|
|
|
|
response['Content-Disposition'] = filename.encode('utf-8')
|
|
|
|
doc = SimpleDocTemplate(response)
|
|
|
|
story = [Spacer(1,3*cm)]
|
|
|
|
|
|
|
|
doc.title = _("Agenda")
|
|
|
|
# print item list
|
|
|
|
items = children_list(Item.objects.filter(parent=None).order_by('weight'))
|
|
|
|
for item in items:
|
|
|
|
if item.hidden is False:
|
2011-09-04 19:06:48 +02:00
|
|
|
# print all items"
|
2011-09-03 01:24:50 +02:00
|
|
|
if item.parents:
|
2011-09-04 19:06:48 +02:00
|
|
|
space = ""
|
2011-09-11 17:06:32 +02:00
|
|
|
counter = 0
|
2011-09-04 19:06:48 +02:00
|
|
|
for p in item.parents:
|
2011-09-11 17:06:32 +02:00
|
|
|
if counter != 0:
|
|
|
|
space += " "
|
|
|
|
counter += 1
|
2011-09-04 19:06:48 +02:00
|
|
|
story.append(Paragraph(space+item.title, stylesheet['Subitem']))
|
2011-07-31 10:46:29 +02:00
|
|
|
else:
|
2011-09-03 01:24:50 +02:00
|
|
|
story.append(Paragraph(item.title, stylesheet['Item']))
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
doc.build(story, onFirstPage=firstPage, onLaterPages=laterPages)
|
|
|
|
return response
|
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-09-21 21:01:00 +02:00
|
|
|
@permission_required('participant.can_see_participant')
|
2011-07-31 10:46:29 +02:00
|
|
|
def print_userlist(request):
|
|
|
|
response = HttpResponse(mimetype='application/pdf')
|
|
|
|
filename = u'filename=%s.pdf;' % _("Participant-list")
|
|
|
|
response['Content-Disposition'] = filename.encode('utf-8')
|
|
|
|
doc = SimpleDocTemplate(response)
|
|
|
|
story = [Spacer(1,2*cm)]
|
|
|
|
|
|
|
|
doc.title = _("List of Participants")
|
|
|
|
# Table
|
|
|
|
data= [['#', _('Last Name'), _('First Name'), _('Group'), _('Type'), _('Committee')]]
|
|
|
|
sort = 'last_name'
|
|
|
|
counter = 0
|
|
|
|
for user in User.objects.all().order_by(sort):
|
|
|
|
try:
|
|
|
|
counter += 1
|
|
|
|
user.get_profile()
|
|
|
|
data.append([counter,
|
2011-09-02 15:54:13 +02:00
|
|
|
Paragraph(user.last_name, stylesheet['Tablecell']),
|
|
|
|
Paragraph(user.first_name, stylesheet['Tablecell']),
|
|
|
|
Paragraph(user.profile.group, stylesheet['Tablecell']),
|
2011-09-21 21:01:56 +02:00
|
|
|
Paragraph(user.profile.get_type_display(), stylesheet['Tablecell']),
|
2011-09-02 15:54:13 +02:00
|
|
|
Paragraph(user.profile.committee, stylesheet['Tablecell']),
|
2011-07-31 10:46:29 +02:00
|
|
|
])
|
|
|
|
except Profile.DoesNotExist:
|
|
|
|
counter -= 1
|
|
|
|
pass
|
|
|
|
|
|
|
|
t=LongTable(data,
|
|
|
|
style=[
|
|
|
|
('VALIGN',(0,0),(-1,-1), 'TOP'),
|
|
|
|
('LINEABOVE',(0,0),(-1,0),2,colors.black),
|
|
|
|
('LINEABOVE',(0,1),(-1,1),1,colors.black),
|
|
|
|
('LINEBELOW',(0,-1),(-1,-1),2,colors.black),
|
|
|
|
('ROWBACKGROUNDS', (0, 1), (-1, -1), (colors.white, (.9, .9, .9))),
|
|
|
|
])
|
|
|
|
t._argW[0]=0.75*cm
|
|
|
|
story.append(t)
|
|
|
|
doc.build(story, onFirstPage=firstPage, onLaterPages=laterPages)
|
|
|
|
return response
|
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-09-04 12:21:58 +02:00
|
|
|
@permission_required('participant.can_manage_participant')
|
2011-09-04 00:54:45 +02:00
|
|
|
def print_passwords(request):
|
|
|
|
response = HttpResponse(mimetype='application/pdf')
|
|
|
|
filename = u'filename=%s.pdf;' % _("passwords")
|
|
|
|
response['Content-Disposition'] = filename.encode('utf-8')
|
|
|
|
doc = SimpleDocTemplate(response, pagesize=A4, topMargin=-6, bottomMargin=-6, leftMargin=0, rightMargin=0, showBoundary=False)
|
|
|
|
story = [Spacer(0,0*cm)]
|
|
|
|
|
|
|
|
data= []
|
|
|
|
system_url = config_get("system_url")
|
|
|
|
system_welcometext = config_get("system_welcometext")
|
|
|
|
for user in User.objects.all().order_by('last_name'):
|
|
|
|
try:
|
|
|
|
user.get_profile()
|
|
|
|
cell = []
|
|
|
|
cell.append(Spacer(0,0.8*cm))
|
2011-09-04 12:21:58 +02:00
|
|
|
cell.append(Paragraph(_("Your Account for OpenSlides"), stylesheet['Ballot_title']))
|
2011-09-05 09:14:38 +02:00
|
|
|
cell.append(Paragraph(_("for %s") % (user.profile), stylesheet['Ballot_subtitle']))
|
2011-09-04 00:54:45 +02:00
|
|
|
cell.append(Spacer(0,0.5*cm))
|
2011-09-05 09:14:38 +02:00
|
|
|
cell.append(Paragraph(_("User: %s") % (user.username), stylesheet['Ballot_option']))
|
|
|
|
cell.append(Paragraph(_("Password: %s") % (user.profile.firstpassword), stylesheet['Ballot_option']))
|
2011-09-04 00:54:45 +02:00
|
|
|
cell.append(Spacer(0,0.5*cm))
|
2011-09-05 09:14:38 +02:00
|
|
|
cell.append(Paragraph(_("URL: %s") % (system_url), stylesheet['Ballot_option']))
|
2011-09-04 00:54:45 +02:00
|
|
|
cell.append(Spacer(0,0.5*cm))
|
|
|
|
cell2 = []
|
|
|
|
cell2.append(Spacer(0,0.8*cm))
|
2011-09-04 08:23:03 +02:00
|
|
|
if system_welcometext is not None:
|
|
|
|
cell2.append(Paragraph(system_welcometext.replace('\r\n','<br/>'), stylesheet['Ballot_subtitle']))
|
2011-09-05 09:14:38 +02:00
|
|
|
|
2011-09-04 00:54:45 +02:00
|
|
|
data.append([cell,cell2])
|
|
|
|
except Profile.DoesNotExist:
|
|
|
|
pass
|
|
|
|
|
|
|
|
t=Table(data, 10.5*cm, 7.42*cm)
|
|
|
|
t.setStyle(TableStyle([ ('LINEBELOW', (0,0), (-1,0), 0.25, colors.grey),
|
|
|
|
('LINEBELOW', (0,1), (-1,1), 0.25, colors.grey),
|
|
|
|
('LINEBELOW', (0,1), (-1,-1), 0.25, colors.grey),
|
|
|
|
('VALIGN', (0,0), (-1,-1), 'TOP'),
|
|
|
|
]))
|
|
|
|
story.append(t)
|
|
|
|
doc.build(story)
|
|
|
|
return response
|
2011-09-04 09:34:52 +02:00
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-09-02 16:34:12 +02:00
|
|
|
def get_application(application, story):
|
2011-09-06 22:22:29 +02:00
|
|
|
# application number
|
2011-09-07 20:37:56 +02:00
|
|
|
if application.number:
|
2011-09-06 23:23:05 +02:00
|
|
|
story.append(Paragraph(_("Application No.")+" %s" % application.number, stylesheet['Heading1']))
|
2011-09-07 20:37:56 +02:00
|
|
|
else:
|
|
|
|
story.append(Paragraph(_("Application No."), stylesheet['Heading1']))
|
|
|
|
|
2011-09-06 22:22:29 +02:00
|
|
|
|
|
|
|
# submitter
|
|
|
|
cell1a = []
|
2011-09-06 23:01:21 +02:00
|
|
|
cell1a.append(Spacer(0,0.2*cm))
|
2011-09-06 22:22:29 +02:00
|
|
|
cell1a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Submitter"), stylesheet['Heading4']))
|
|
|
|
cell1b = []
|
2011-09-06 23:01:21 +02:00
|
|
|
cell1b.append(Spacer(0,0.2*cm))
|
|
|
|
if application.status == "pub":
|
|
|
|
cell1b.append(Paragraph("__________________________________________",stylesheet['Signaturefield']))
|
2011-09-07 18:43:25 +02:00
|
|
|
cell1b.append(Spacer(0,0.1*cm))
|
2011-09-06 23:01:21 +02:00
|
|
|
cell1b.append(Paragraph(" "+unicode(application.submitter.profile), stylesheet['Small']))
|
2011-09-07 18:43:25 +02:00
|
|
|
cell1b.append(Spacer(0,0.2*cm))
|
2011-09-06 23:01:21 +02:00
|
|
|
else:
|
|
|
|
cell1b.append(Paragraph(unicode(application.submitter.profile), stylesheet['Normal']))
|
2011-09-06 22:22:29 +02:00
|
|
|
|
|
|
|
# supporters
|
|
|
|
cell2a = []
|
|
|
|
cell2a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>" % _("Supporters"), stylesheet['Heading4']))
|
|
|
|
cell2b = []
|
2011-09-02 16:34:12 +02:00
|
|
|
for s in application.supporter.all():
|
2011-09-06 22:22:29 +02:00
|
|
|
cell2b.append(Paragraph("<seq id='counter'/>. %s" % unicode(s.profile), stylesheet['Signaturefield']))
|
2011-09-06 23:23:05 +02:00
|
|
|
if application.status == "pub":
|
|
|
|
for x in range(0,application.missing_supporters):
|
|
|
|
cell2b.append(Paragraph("<seq id='counter'/>. __________________________________________",stylesheet['Signaturefield']))
|
2011-09-06 22:22:29 +02:00
|
|
|
cell2b.append(Spacer(0,0.2*cm))
|
|
|
|
|
|
|
|
# status
|
2011-09-02 16:34:12 +02:00
|
|
|
note = ""
|
|
|
|
for n in application.notes:
|
|
|
|
note += "%s " % unicode(n)
|
2011-09-06 22:22:29 +02:00
|
|
|
cell3a = []
|
|
|
|
cell3a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Status"), stylesheet['Heading4']))
|
|
|
|
cell3b = []
|
2011-09-02 16:34:12 +02:00
|
|
|
if note != "":
|
2011-09-07 18:43:25 +02:00
|
|
|
if application.status == "pub":
|
|
|
|
cell3b.append(Paragraph(note, stylesheet['Normal']))
|
|
|
|
else:
|
|
|
|
cell3b.append(Paragraph("%s | %s" % (application.get_status_display(), note), stylesheet['Normal']))
|
2011-09-02 16:34:12 +02:00
|
|
|
else:
|
2011-09-06 22:22:29 +02:00
|
|
|
cell3b.append(Paragraph("%s" % application.get_status_display(), stylesheet['Normal']))
|
|
|
|
|
|
|
|
# table
|
|
|
|
data = []
|
|
|
|
data.append([cell1a,cell1b])
|
|
|
|
data.append([cell2a,cell2b])
|
|
|
|
data.append([cell3a,cell3b])
|
2011-09-07 20:37:56 +02:00
|
|
|
|
|
|
|
# voting results
|
|
|
|
if len(application.results) > 0:
|
|
|
|
cell4a = []
|
|
|
|
cell4a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Vote results"), stylesheet['Heading4']))
|
|
|
|
cell4b = []
|
|
|
|
ballotcounter = 0
|
|
|
|
for result in application.results:
|
|
|
|
ballotcounter += 1
|
|
|
|
if len(application.results) > 1:
|
|
|
|
cell4b.append(Paragraph("%s. %s" % (ballotcounter, _("Vote")), stylesheet['Bold']))
|
|
|
|
cell4b.append(Paragraph("%s: %s <br/> %s: %s <br/> %s: %s <br/> %s: %s <br/> %s: %s" % (_("Yes"), result[0], _("No"), result[1], _("Abstention"), result[2], _("Invalid"), result[3], _("Votes cast"), result[4]), stylesheet['Normal']))
|
|
|
|
cell4b.append(Spacer(0,0.2*cm))
|
|
|
|
data.append([cell4a,cell4b])
|
|
|
|
|
2011-09-06 22:22:29 +02:00
|
|
|
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))
|
2011-09-07 18:43:25 +02:00
|
|
|
|
|
|
|
# title
|
|
|
|
story.append(Paragraph(application.title, stylesheet['Heading3']))
|
2011-09-06 22:22:29 +02:00
|
|
|
# text
|
|
|
|
story.append(Paragraph("%s" % application.text.replace('\r\n','<br/>'), stylesheet['Paragraph']))
|
|
|
|
# reason
|
|
|
|
story.append(Paragraph(_("Reason")+":", stylesheet['Heading3']))
|
|
|
|
story.append(Paragraph("%s" % application.reason.replace('\r\n','<br/>'), stylesheet['Paragraph']))
|
2011-09-02 16:34:12 +02:00
|
|
|
return story
|
2011-09-04 09:34:52 +02:00
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-09-04 12:21:58 +02:00
|
|
|
@permission_required('application.can_see_application')
|
2011-07-31 10:46:29 +02:00
|
|
|
def print_application(request, application_id=None):
|
|
|
|
response = HttpResponse(mimetype='application/pdf')
|
|
|
|
filename = u'filename=%s.pdf;' % _("Applications")
|
|
|
|
response['Content-Disposition'] = filename.encode('utf-8')
|
|
|
|
doc = SimpleDocTemplate(response)
|
2011-09-02 16:34:12 +02:00
|
|
|
doc.title = None
|
2011-09-06 22:22:29 +02:00
|
|
|
story = []
|
|
|
|
|
2011-09-02 16:34:12 +02:00
|
|
|
if application_id is None: #print all applications
|
2011-10-05 21:18:28 +02:00
|
|
|
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']))
|
2011-09-07 07:52:44 +02:00
|
|
|
story.append(Spacer(0,0.75*cm))
|
2011-09-02 16:34:12 +02:00
|
|
|
# List of applications
|
2011-09-07 20:37:56 +02:00
|
|
|
for application in Application.objects.order_by('number'):
|
|
|
|
if application.number:
|
|
|
|
story.append(Paragraph(_("Application No.")+" %s: %s" % (application.number, application.title), stylesheet['Heading3']))
|
|
|
|
else:
|
|
|
|
story.append(Paragraph(_("Application No.")+" : %s" % (application.title), stylesheet['Heading3']))
|
2011-09-02 16:34:12 +02:00
|
|
|
# Applications details (each application on single page)
|
2011-09-07 20:37:56 +02:00
|
|
|
for application in Application.objects.order_by('number'):
|
2011-07-31 10:46:29 +02:00
|
|
|
story.append(PageBreak())
|
2011-09-02 16:34:12 +02:00
|
|
|
story = get_application(application, story)
|
|
|
|
else: # print selected application
|
2011-07-31 10:46:29 +02:00
|
|
|
application = Application.objects.get(id=application_id)
|
2011-09-07 20:37:56 +02:00
|
|
|
if application.number:
|
|
|
|
number = application.number
|
|
|
|
else:
|
|
|
|
number = ""
|
|
|
|
filename = u'filename=%s%s.pdf;' % (_("Application"), str(number))
|
2011-07-31 10:46:29 +02:00
|
|
|
response['Content-Disposition'] = filename.encode('utf-8')
|
2011-09-02 16:34:12 +02:00
|
|
|
story = get_application(application, story)
|
2011-09-05 09:14:38 +02:00
|
|
|
|
2011-09-06 22:22:29 +02:00
|
|
|
doc.build(story, onFirstPage=firstPage, onLaterPages=firstPage)
|
2011-07-31 10:46:29 +02:00
|
|
|
return response
|
|
|
|
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-09-04 09:34:52 +02:00
|
|
|
@permission_required('application.can_manage_application')
|
2011-07-31 10:46:29 +02:00
|
|
|
def print_application_poll(request, poll_id=None):
|
|
|
|
poll = Poll.objects.get(id=poll_id)
|
|
|
|
response = HttpResponse(mimetype='application/pdf')
|
|
|
|
filename = u'filename=%s%s_%s.pdf;' % (_("Application"), str(poll.application.number), _("Poll"))
|
|
|
|
response['Content-Disposition'] = filename.encode('utf-8')
|
|
|
|
doc = SimpleDocTemplate(response, pagesize=A4, topMargin=-6, bottomMargin=-6, leftMargin=0, rightMargin=0, showBoundary=False)
|
|
|
|
story = [Spacer(0,0*cm)]
|
2011-09-05 09:14:38 +02:00
|
|
|
|
2011-09-04 08:31:44 +02:00
|
|
|
imgpath = os.path.join(SITE_ROOT, 'static/images/circle.png')
|
|
|
|
circle = "<img src='%s' width='15' height='15'/> " % imgpath
|
2011-07-31 10:46:29 +02:00
|
|
|
cell = []
|
|
|
|
cell.append(Spacer(0,0.8*cm))
|
2011-09-06 23:23:05 +02:00
|
|
|
cell.append(Paragraph(_("Application No.")+" "+str(poll.application.number), stylesheet['Ballot_title']))
|
2011-09-03 10:52:29 +02:00
|
|
|
cell.append(Paragraph(poll.application.title, stylesheet['Ballot_subtitle']))
|
|
|
|
cell.append(Paragraph(str(poll.ballot)+". "+_("Vote"), stylesheet['Ballot_description']))
|
2011-07-31 10:46:29 +02:00
|
|
|
cell.append(Spacer(0,0.5*cm))
|
2011-09-02 17:39:32 +02:00
|
|
|
cell.append(Paragraph(circle+_("Yes"), stylesheet['Ballot_option']))
|
|
|
|
cell.append(Paragraph(circle+_("No"), stylesheet['Ballot_option']))
|
|
|
|
cell.append(Paragraph(circle+_("Abstention"), stylesheet['Ballot_option']))
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
data= []
|
|
|
|
for user in xrange(User.objects.count()/2):
|
|
|
|
data.append([cell,cell])
|
|
|
|
t=Table(data, 10.5*cm, 7.42*cm)
|
|
|
|
t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey),
|
|
|
|
('VALIGN', (0,0), (-1,-1), 'TOP'),
|
|
|
|
]))
|
|
|
|
story.append(t)
|
|
|
|
doc.build(story)
|
|
|
|
return response
|
|
|
|
|
2011-09-09 16:18:11 +02:00
|
|
|
def get_assignment_votes(assignment):
|
|
|
|
votes = []
|
|
|
|
for candidate in assignment.candidates:
|
|
|
|
tmplist = [[candidate, assignment.is_elected(candidate)], []]
|
|
|
|
for poll in assignment.poll_set.all():
|
|
|
|
if poll.published:
|
|
|
|
if candidate in poll.options_values:
|
|
|
|
option = Option.objects.filter(poll=poll).filter(user=candidate)[0]
|
|
|
|
if poll.optiondecision:
|
|
|
|
tmplist[1].append([option.yes, option.no, option.undesided])
|
|
|
|
else:
|
|
|
|
tmplist[1].append(option.yes)
|
|
|
|
else:
|
|
|
|
tmplist[1].append("-")
|
2011-09-11 18:37:20 +02:00
|
|
|
elif len(tmplist[1]) == 0:
|
|
|
|
return votes
|
2011-09-09 16:18:11 +02:00
|
|
|
votes.append(tmplist)
|
|
|
|
return votes
|
|
|
|
|
2011-09-07 07:52:44 +02:00
|
|
|
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("<font name='Ubuntu-Bold'>%s:</font>" % _("Number of available posts"), stylesheet['Bold']))
|
|
|
|
cell1b = []
|
|
|
|
cell1b.append(Paragraph(str(assignment.posts), stylesheet['Paragraph']))
|
|
|
|
# candidates
|
|
|
|
cell2a = []
|
|
|
|
cell2a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>" % _("Candidates"), stylesheet['Heading4']))
|
|
|
|
cell2b = []
|
2011-09-21 21:24:56 +02:00
|
|
|
for c in assignment.profile.all():
|
2011-09-07 07:52:44 +02:00
|
|
|
cell2b.append(Paragraph("<seq id='counter'/>. %s" % unicode(c), stylesheet['Signaturefield']))
|
|
|
|
if assignment.status == "sea":
|
|
|
|
for x in range(0,2*assignment.posts):
|
|
|
|
cell2b.append(Paragraph("<seq id='counter'/>. __________________________________________",stylesheet['Signaturefield']))
|
|
|
|
cell2b.append(Spacer(0,0.2*cm))
|
2011-09-09 16:18:11 +02:00
|
|
|
# vote results
|
|
|
|
table_votes = []
|
|
|
|
results = get_assignment_votes(assignment)
|
|
|
|
cell3a = []
|
|
|
|
cell3a.append(Paragraph("%s:" % (_("Vote results")), stylesheet['Heading4']))
|
2011-09-11 18:37:20 +02:00
|
|
|
if len(results) > 0:
|
|
|
|
if len(results[0]) >= 1:
|
|
|
|
cell3a.append(Paragraph("%s %s" % (len(results[0][1]), _("ballots")), stylesheet['Normal']))
|
|
|
|
if len(results[0][1]) > 0:
|
|
|
|
data_votes = []
|
|
|
|
# add table head row
|
|
|
|
headrow = []
|
|
|
|
headrow.append(_("Candidates"))
|
|
|
|
for i in range (0,len(results[0][1])):
|
|
|
|
headrow.append("%s." %(str(i+1)))
|
|
|
|
data_votes.append(headrow)
|
|
|
|
# add result rows
|
|
|
|
for candidate in results:
|
|
|
|
row = []
|
2011-09-29 22:14:46 +02:00
|
|
|
if candidate[0][1]:
|
|
|
|
elected = "* "
|
|
|
|
else:
|
|
|
|
elected = ""
|
|
|
|
row.append(elected+str(candidate[0][0]))
|
2011-09-11 18:37:20 +02:00
|
|
|
for votes in candidate[1]:
|
|
|
|
if type(votes) == type(list()):
|
|
|
|
tmp = "list"
|
|
|
|
tmp = _("Yes")+": "+str(votes[0])+"\n"
|
|
|
|
tmp += _("No")+": "+str(votes[1])+"\n"
|
|
|
|
tmp += _("Abstention")+": "+str(votes[2])
|
|
|
|
row.append(tmp)
|
|
|
|
else:
|
|
|
|
row.append(str(votes))
|
|
|
|
|
|
|
|
data_votes.append(row)
|
|
|
|
polls = []
|
|
|
|
for poll in assignment.poll_set.filter(assignment=assignment):
|
|
|
|
polls.append(poll)
|
|
|
|
# votes invalid
|
2011-09-09 16:18:11 +02:00
|
|
|
row = []
|
2011-09-11 18:37:20 +02:00
|
|
|
row.append(_("Invalid votes"))
|
|
|
|
for p in polls:
|
|
|
|
if p.published:
|
2011-09-21 21:28:27 +02:00
|
|
|
row.append(p.votesinvalidf)
|
2011-09-09 16:18:11 +02:00
|
|
|
data_votes.append(row)
|
2011-09-11 18:37:20 +02:00
|
|
|
|
|
|
|
# votes cast
|
|
|
|
row = []
|
|
|
|
row.append(_("Votes cast"))
|
|
|
|
for p in polls:
|
|
|
|
if p.published:
|
2011-09-21 21:28:27 +02:00
|
|
|
row.append(p.votescastf)
|
2011-09-11 18:37:20 +02:00
|
|
|
data_votes.append(row)
|
|
|
|
|
|
|
|
table_votes=Table(data_votes)
|
|
|
|
table_votes.setStyle( TableStyle([
|
|
|
|
('GRID', (0,0), (-1,-1), 0.5, colors.grey),
|
|
|
|
('VALIGN',(0,0),(-1,-1), 'TOP'),
|
|
|
|
('LINEABOVE',(0,0),(-1,0),2,colors.black),
|
|
|
|
('LINEABOVE',(0,1),(-1,1),1,colors.black),
|
|
|
|
('LINEBELOW',(0,-1),(-1,-1),2,colors.black),
|
|
|
|
('ROWBACKGROUNDS', (0, 1), (-1, -1), (colors.white, (.9, .9, .9))),
|
|
|
|
]))
|
2011-09-09 16:18:11 +02:00
|
|
|
|
2011-09-07 07:52:44 +02:00
|
|
|
# table
|
|
|
|
data = []
|
|
|
|
data.append([cell1a,cell1b])
|
2011-09-09 16:18:11 +02:00
|
|
|
if table_votes:
|
|
|
|
data.append([cell3a,table_votes])
|
2011-09-29 22:14:46 +02:00
|
|
|
data.append(['','* = '+_('elected')])
|
2011-09-11 18:37:20 +02:00
|
|
|
else:
|
|
|
|
data.append([cell2a,cell2b])
|
2011-09-09 16:18:11 +02:00
|
|
|
data.append([Spacer(0,0.2*cm),''])
|
2011-09-07 07:52:44 +02:00
|
|
|
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','<br/>'), 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
|
2011-10-05 21:18:28 +02:00
|
|
|
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']))
|
2011-09-07 07:52:44 +02:00
|
|
|
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)
|
2011-09-06 09:17:39 +02:00
|
|
|
|
2011-09-07 07:52:44 +02:00
|
|
|
doc.build(story, onFirstPage=firstPage, onLaterPages=firstPage)
|
|
|
|
return response
|
|
|
|
|
2011-09-04 09:34:52 +02:00
|
|
|
@permission_required('application.can_manage_application')
|
2011-09-03 10:52:29 +02:00
|
|
|
def print_assignment_poll(request, poll_id=None):
|
2011-07-31 10:46:29 +02:00
|
|
|
poll = Poll.objects.get(id=poll_id)
|
|
|
|
response = HttpResponse(mimetype='application/pdf')
|
2011-09-03 10:52:29 +02:00
|
|
|
filename = u'filename=%s-%s-#%s.pdf;' % (_("Election"), poll.assignment.name.replace(' ','_'), poll.ballot)
|
2011-07-31 10:46:29 +02:00
|
|
|
response['Content-Disposition'] = filename.encode('utf-8')
|
|
|
|
doc = SimpleDocTemplate(response, pagesize=A4, topMargin=-6, bottomMargin=-6, leftMargin=0, rightMargin=0, showBoundary=False)
|
|
|
|
story = [Spacer(0,0*cm)]
|
2011-09-05 09:14:38 +02:00
|
|
|
|
2011-09-04 08:31:44 +02:00
|
|
|
imgpath = os.path.join(SITE_ROOT, 'static/images/circle.png')
|
|
|
|
circle = "<img src='%s' width='15' height='15'/> " % imgpath
|
2011-07-31 10:46:29 +02:00
|
|
|
cell = []
|
|
|
|
cell.append(Spacer(0,0.8*cm))
|
2011-09-03 10:52:29 +02:00
|
|
|
cell.append(Paragraph(_("Election") + ": " + poll.assignment.name, stylesheet['Ballot_title']))
|
2011-09-02 17:39:32 +02:00
|
|
|
cell.append(Paragraph(poll.description, stylesheet['Ballot_subtitle']))
|
2011-07-31 10:46:29 +02:00
|
|
|
options = poll.get_options().order_by('user__user__first_name')
|
2011-09-03 10:52:29 +02:00
|
|
|
cell.append(Paragraph(str(poll.ballot)+". "+_("ballot")+", "+str(len(options))+" "+ ungettext("candidate", "candidates", len(options))+", "+str(poll.assignment.posts)+" "+_("available posts"), stylesheet['Ballot_description']))
|
2011-07-31 10:46:29 +02:00
|
|
|
cell.append(Spacer(0,0.4*cm))
|
2011-09-05 09:14:38 +02:00
|
|
|
|
2011-09-03 10:52:29 +02:00
|
|
|
if poll.optiondecision:
|
2011-07-31 10:46:29 +02:00
|
|
|
for option in options:
|
2011-09-21 21:13:54 +02:00
|
|
|
o = str(option).split("(",1)
|
2011-09-02 17:39:32 +02:00
|
|
|
cell.append(Paragraph(o[0], stylesheet['Ballot_option_name']))
|
2011-07-31 10:46:29 +02:00
|
|
|
if len(o) > 1:
|
2011-09-02 17:39:32 +02:00
|
|
|
cell.append(Paragraph("("+o[1], stylesheet['Ballot_option_group']))
|
2011-07-31 10:46:29 +02:00
|
|
|
else:
|
2011-09-02 17:39:32 +02:00
|
|
|
cell.append(Paragraph(" ", stylesheet['Ballot_option_group']))
|
|
|
|
cell.append(Paragraph(circle+_("Yes")+" "+circle+_("No")+" "+circle+_("Abstention"), stylesheet['Ballot_option_YNA']))
|
2011-07-31 10:46:29 +02:00
|
|
|
data= []
|
|
|
|
for user in xrange(User.objects.count()/2):
|
|
|
|
data.append([cell,cell])
|
|
|
|
if len(options) <= 2:
|
|
|
|
t=Table(data, 10.5*cm, 7.42*cm)
|
|
|
|
elif len(options) <= 5:
|
|
|
|
t=Table(data, 10.5*cm, 14.84*cm)
|
|
|
|
else:
|
|
|
|
t=Table(data, 10.5*cm, 29.7*cm)
|
|
|
|
else:
|
|
|
|
for option in options:
|
2011-09-21 21:13:54 +02:00
|
|
|
o = str(option).split("(",1)
|
2011-09-02 17:39:32 +02:00
|
|
|
cell.append(Paragraph(circle+o[0], stylesheet['Ballot_option_name']))
|
2011-07-31 10:46:29 +02:00
|
|
|
if len(o) > 1:
|
2011-09-02 17:39:32 +02:00
|
|
|
cell.append(Paragraph("("+o[1], stylesheet['Ballot_option_group_right']))
|
2011-07-31 10:46:29 +02:00
|
|
|
else:
|
2011-09-02 17:39:32 +02:00
|
|
|
cell.append(Paragraph(" ", stylesheet['Ballot_option_group_right']))
|
2011-07-31 10:46:29 +02:00
|
|
|
data= []
|
|
|
|
for user in xrange(User.objects.count()/2):
|
|
|
|
data.append([cell,cell])
|
|
|
|
if len(options) <= 4:
|
|
|
|
t=Table(data, 10.5*cm, 7.42*cm)
|
|
|
|
elif len(options) <= 8:
|
|
|
|
t=Table(data, 10.5*cm, 14.84*cm)
|
|
|
|
else:
|
|
|
|
t=Table(data, 10.5*cm, 29.7*cm)
|
2011-09-05 09:14:38 +02:00
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey),
|
|
|
|
('VALIGN', (0,0), (-1,-1), 'TOP'),
|
|
|
|
]))
|
|
|
|
story.append(t)
|
|
|
|
doc.build(story)
|
|
|
|
return response
|