Automated merge with ssh://openslides.org/openslides

This commit is contained in:
Emanuel Schuetze 2012-04-13 23:52:48 +02:00
commit 3817a03aa8
8 changed files with 478 additions and 308 deletions

View File

@ -13,7 +13,7 @@
from django.conf.urls.defaults import *
from agenda.views import Overview, View, SetActive, SetClosed, ItemUpdate, ItemCreate, ItemDelete, ItemPDF
urlpatterns = patterns('agenda.views',
urlpatterns = patterns('',
url(r'^$',
Overview.as_view(),
name='item_overview',

View File

@ -13,84 +13,127 @@
from django.conf.urls.defaults import *
from django.utils.translation import ugettext as _
from application.views import ViewPoll, ActivatePoll
from application.views import ViewPoll, ActivatePoll, ApplicationPDF, ApplicationPollPDF
urlpatterns = patterns('application.views',
url(r'^application/$', 'overview', \
name='application_overview'),
url(r'^$',
'overview',
name='application_overview',
),
url(r'^application/(?P<application_id>\d+)/$', 'view', \
name='application_view'),
url(r'^(?P<application_id>\d+)/$',
'view',
name='application_view',
),
url(r'^application/(?P<application_id>\d+)/newest/$', 'view', {'newest': True}, \
name='application_view_newest'),
url(r'^(?P<application_id>\d+)/newest/$',
'view',
{'newest': True},
name='application_view_newest',
),
url(r'^application/new/$', 'edit', \
name='application_new'),
url(r'^new/$',
'edit',
name='application_new',
),
url(r'^application/import/$', 'application_import', \
name='application_import'),
url(r'^import/$',
'application_import',
name='application_import',
),
url(r'^application/(?P<application_id>\d+)/edit/$', 'edit', \
name='application_edit'),
url(r'^(?P<application_id>\d+)/edit/$',
'edit',
name='application_edit',
),
url(r'^application/(?P<application_id>\d+)/del/$', 'delete', \
name='application_delete'),
url(r'^(?P<application_id>\d+)/del/$',
'delete',
name='application_delete',
),
url(r'^application/(?P<application_id>\d+)/setnumber/$', 'set_number', \
name='application_set_number'),
url(r'^(?P<application_id>\d+)/setnumber/$',
'set_number',
name='application_set_number',
),
url(r'^application/(?P<application_id>\d+)/setstatus/' \
'(?P<status>[a-z]{3})/$', 'set_status', \
name='application_set_status'),
url(r'^(?P<application_id>\d+)/setstatus/' '(?P<status>[a-z]{3})/$',
'set_status',
name='application_set_status',
),
url(r'^application/(?P<application_id>\d+)/permit/$', 'permit', \
name='application_permit'),
url(r'^(?P<application_id>\d+)/permit/$',
'permit',
name='application_permit',
),
url(r'^application/version/(?P<aversion_id>\d+)/permit/$', 'permit_version', \
name='application_version_permit'),
url(r'^version/(?P<aversion_id>\d+)/permit/$',
'permit_version',
name='application_version_permit',
),
url(r'^application/version/(?P<aversion_id>\d+)/reject/$', 'reject_version', \
name='application_version_reject'),
url(r'^version/(?P<aversion_id>\d+)/reject/$',
'reject_version',
name='application_version_reject',
),
url(r'^application/(?P<application_id>\d+)/notpermit/$', 'notpermit', \
name='application_notpermit'),
url(r'^(?P<application_id>\d+)/notpermit/$',
'notpermit',
name='application_notpermit',
),
url(r'^application/(?P<application_id>\d+)/reset/$', 'reset', \
name='application_reset'),
url(r'^(?P<application_id>\d+)/reset/$',
'reset',
name='application_reset',
),
url(r'^application/(?P<application_id>\d+)/support/$', 'support', \
name='application_support'),
url(r'^(?P<application_id>\d+)/support/$',
'support',
name='application_support',
),
url(r'^application/(?P<application_id>\d+)/unsupport/$', 'unsupport', \
name='application_unsupport'),
url(r'^(?P<application_id>\d+)/unsupport/$',
'unsupport',
name='application_unsupport',
),
url(r'^application/(?P<application_id>\d+)/set_active/$', 'set_active',
name='application_activate_item'),
url(r'^(?P<application_id>\d+)/set_active/$',
'set_active',
name='application_activate_item',
),
url(r'^application/(?P<application_id>\d+)/gen_poll/$', 'gen_poll', \
name='application_gen_poll'),
url(r'^(?P<application_id>\d+)/gen_poll/$',
'gen_poll',
name='application_gen_poll',
),
url(r'^application/print/$', 'print_application', \
name='print_applications'),
url(r'^print/$',
ApplicationPDF.as_view(),
name='print_applications',
),
url(r'^application/(?P<application_id>\d+)/print/$', 'print_application', \
name='print_application'),
url(r'^(?P<application_id>\d+)/print/$',
ApplicationPDF.as_view(),
name='print_application',
),
url(r'^application/poll/(?P<poll_id>\d+)/print/$', 'print_application_poll', \
name='print_application_poll'),
url(r'^poll/(?P<poll_id>\d+)/print/$',
ApplicationPollPDF.as_view(),
name='print_application_poll',
),
url(r'^application/poll/(?P<poll_id>\d+)/$',
url(r'^poll/(?P<poll_id>\d+)/$',
ViewPoll.as_view(),
name='application_poll_view',
),
url(r'^application/poll/(?P<poll_id>\d+)/activate/$',
url(r'^poll/(?P<poll_id>\d+)/activate/$',
ActivatePoll.as_view(),
name='application_poll_activate',
),
url(r'^application/poll/(?P<poll_id>\d+)/del/$', 'delete_poll', \
name='application_poll_delete'),
url(r'^poll/(?P<poll_id>\d+)/del/$',
'delete_poll',
name='application_poll_delete',
),
)

View File

@ -13,6 +13,7 @@ from __future__ import with_statement
import csv
import utils.csv_ext
import os
from django.shortcuts import redirect
from django.contrib import messages
@ -24,7 +25,14 @@ from django.utils.translation import ungettext
from django.db import transaction
from django.views.generic.base import RedirectView
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.platypus import PageBreak, Paragraph, Spacer, Table, TableStyle
from system import config
from settings import SITE_ROOT
from utils.pdf import stylesheet
from utils.views import PDFView
from agenda.models import Item
@ -45,8 +53,6 @@ from utils.utils import template, permission_required, \
from utils.views import FormView
from utils.template import Tab
from utils.pdf import print_application, print_application_poll
from participant.api import gen_username, gen_password
@permission_required('application.can_see_application')
@ -479,7 +485,7 @@ def reject_version(request, aversion_id):
return redirect(reverse('application_view', args=[application.id]))
@permission_required('application.can_manage_applications')
@permission_required('application.can_manage_application')
@template('application/import.html')
def application_import(request):
try:
@ -598,6 +604,177 @@ def application_import(request):
}
class ApplicationPDF(PDFView):
permission_required = 'application.can_manage_application'
filename = u'filename=%s.pdf;' % _("Applications")
top_space = 0
def append_to_pdf(self, story):
try:
application_id = self.kwargs['application_id']
except KeyError:
application_id = None
if application_id is None: #print all applications
title = config["application_pdf_title"]
story.append(Paragraph(title, stylesheet['Heading1']))
preamble = config["application_pdf_preamble"]
if 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'):
if application.number:
story.append(Paragraph(_("Application No.")+" %s: %s" % (application.number, application.title), stylesheet['Heading3']))
else:
story.append(Paragraph(_("Application No.")+"&nbsp;&nbsp;&nbsp;: %s" % (application.title), stylesheet['Heading3']))
# Applications details (each application on single page)
for application in Application.objects.order_by('number'):
story.append(PageBreak())
story = self.get_application(application, story)
else: # print selected application
application = Application.objects.get(id=application_id)
if application.number:
number = application.number
else:
number = ""
filename = u'filename=%s%s.pdf;' % (_("Application"), str(number))
story = self.get_application(application, story)
def get_application(self, application, story):
# application number
if application.number:
story.append(Paragraph(_("Application No.")+" %s" % application.number, stylesheet['Heading1']))
else:
story.append(Paragraph(_("Application No."), stylesheet['Heading1']))
# submitter
cell1a = []
cell1a.append(Spacer(0,0.2*cm))
cell1a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Submitter"), stylesheet['Heading4']))
cell1b = []
cell1b.append(Spacer(0,0.2*cm))
if application.status == "pub":
cell1b.append(Paragraph("__________________________________________",stylesheet['Signaturefield']))
cell1b.append(Spacer(0,0.1*cm))
cell1b.append(Paragraph("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+unicode(application.submitter.profile), stylesheet['Small']))
cell1b.append(Spacer(0,0.2*cm))
else:
cell1b.append(Paragraph(unicode(application.submitter.profile), stylesheet['Normal']))
# supporters
cell2a = []
cell2a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>" % _("Supporters"), stylesheet['Heading4']))
cell2b = []
for s in application.supporter.all():
cell2b.append(Paragraph("<seq id='counter'/>.&nbsp; %s" % unicode(s.profile), stylesheet['Signaturefield']))
if application.status == "pub":
for x in range(0,application.missing_supporters):
cell2b.append(Paragraph("<seq id='counter'/>.&nbsp; __________________________________________",stylesheet['Signaturefield']))
cell2b.append(Spacer(0,0.2*cm))
# status
note = ""
for n in application.notes:
note += "%s " % unicode(n)
cell3a = []
cell3a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Status"), stylesheet['Heading4']))
cell3b = []
if note != "":
if application.status == "pub":
cell3b.append(Paragraph(note, stylesheet['Normal']))
else:
cell3b.append(Paragraph("%s | %s" % (application.get_status_display(), note), stylesheet['Normal']))
else:
cell3b.append(Paragraph("%s" % application.get_status_display(), stylesheet['Normal']))
# table
data = []
data.append([cell1a,cell1b])
data.append([cell2a,cell2b])
data.append([cell3a,cell3b])
# 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])
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))
# title
story.append(Paragraph(application.title, stylesheet['Heading3']))
# 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']))
return story
class ApplicationPollPDF(PDFView):
permission_required = 'application.can_manage_application'
top_space = 0
def get(self, request, *args, **kwargs):
self.poll = ApplicationPoll.objects.get(id=self.kwargs['poll_id'])
return super(ApplicationPollPDF, self).get(request, *args, **kwargs)
def get_filename(self):
filename = u'filename=%s%s_%s.pdf;' % (_("Application"), str(self.poll.application.number), _("Poll"))
return filename
def append_to_pdf(self, story):
imgpath = os.path.join(SITE_ROOT, 'static/images/circle.png')
circle = "<img src='%s' width='15' height='15'/>&nbsp;&nbsp;" % imgpath
cell = []
cell.append(Spacer(0,0.8*cm))
cell.append(Paragraph(_("Application No.")+" "+str(self.poll.application.number), stylesheet['Ballot_title']))
cell.append(Paragraph(self.poll.application.title, stylesheet['Ballot_subtitle']))
#cell.append(Paragraph(str(self.poll.ballot)+". "+_("Vote"), stylesheet['Ballot_description']))
cell.append(Spacer(0,0.5*cm))
cell.append(Paragraph(circle+_("Yes"), stylesheet['Ballot_option']))
cell.append(Paragraph(circle+_("No"), stylesheet['Ballot_option']))
cell.append(Paragraph(circle+_("Abstention"), stylesheet['Ballot_option']))
data= []
number = 1
# get ballot papers config values
ballot_papers_selection = config["application_pdf_ballot_papers_selection"]
ballot_papers_number = config["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])
rest = number % 2
if rest:
data.append([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)
class Config(FormView):
permission_required = 'system.can_manage_system'
form_class = ConfigForm

View File

@ -15,65 +15,106 @@ from django.conf.urls.defaults import *
from assignment.views import ViewPoll #, ActivatePoll
urlpatterns = patterns('assignment.views',
url(r'^assignment/$', 'get_overview', \
name='assignment_overview'),
url(r'^assignment/(?P<assignment_id>\d+)$', 'view', \
name='assignment_view'),
url(r'^assignment/new$', 'edit', \
name='assignment_new'),
url(r'^assignment/(?P<assignment_id>\d+)/edit$', 'edit', \
name='assignment_edit'),
url(r'^assignment/(?P<assignment_id>\d+)/del$', 'delete', \
name='assignment_delete'),
url(r'^assignment/(?P<assignment_id>\d+)/setstatus/(?P<status>[a-z]{3})$', 'set_status', \
name='assignment_set_status'),
url(r'^assignment/(?P<assignment_id>\d+)/run$', 'run', \
name='assignment_run'),
url(r'^assignment/(?P<assignment_id>\d+)/delrun$', 'delrun', \
name='assignment_delrun'),
url(r'^assignment/(?P<assignment_id>\d+)/delother/(?P<profile_id>\d+)$', 'delother', \
name='assignment_delother'),
url(r'^assignment/(?P<assignment_id>\d+)/set_active/$', 'set_active',
name='assignment_activate_item'),
url(r'^assignment/poll/(?P<poll_id>\d+)/print$', 'print_assignment_poll', \
name='print_assignment_poll'),
url(r'^assignment/print$', 'print_assignment', \
name='print_assignment'),
url(r'^assignment/(?P<assignment_id>\d+)/print$', 'print_assignment', \
name='print_assignment'),
url(r'^assignment/(?P<assignment_id>\d+)/gen_poll$', 'gen_poll', \
name='assignment_gen_poll'),
url(r'^assignment/poll/(?P<poll_id>\d+)$',
ViewPoll.as_view(),
name='assignment_poll_view'
url(r'^$',
'get_overview',
name='assignment_overview',
),
url(r'^assignment/poll/(?P<poll_id>\d+)/del$', 'delete_poll', \
name='assignment_poll_delete'),
url(r'^(?P<assignment_id>\d+)$',
'view',
name='assignment_view'),
url(r'^assignment/poll/(?P<poll_id>\d+)/pub/$', 'set_published', {'published': True},
name='assignment_poll_publish'),
url(r'^new$',
'edit',
name='assignment_new',
),
url(r'^assignment/poll/(?P<poll_id>\d+)/notpub/$', 'set_published', {'published': False},
name='assignment_poll_notpublish'),
url(r'^(?P<assignment_id>\d+)/edit$',
'edit',
name='assignment_edit',
),
url(r'^assignment/(?P<assignment_id>\d+)/elected/(?P<profile_id>\d+)$', 'set_elected', {'elected': True}, \
name='assignment_user_elected'),
url(r'^(?P<assignment_id>\d+)/del$',
'delete',
name='assignment_delete',
),
url(r'^assignment/(?P<assignment_id>\d+)/notelected/(?P<profile_id>\d+)$', 'set_elected', {'elected': False}, \
name='assignment_user_not_elected'),
url(r'^(?P<assignment_id>\d+)/setstatus/(?P<status>[a-z]{3})$',
'set_status',
name='assignment_set_status',
),
url(r'^(?P<assignment_id>\d+)/run$',
'run',
name='assignment_run',
),
url(r'^(?P<assignment_id>\d+)/delrun$',
'delrun',
name='assignment_delrun',
),
url(r'^(?P<assignment_id>\d+)/delother/(?P<profile_id>\d+)$',
'delother',
name='assignment_delother',
),
url(r'^(?P<assignment_id>\d+)/set_active/$',
'set_active',
name='assignment_activate_item',
),
url(r'^poll/(?P<poll_id>\d+)/print$',
'print_assignment_poll',
name='print_assignment_poll',
),
url(r'^print$',
'print_assignment',
name='print_assignment',
),
url(r'^(?P<assignment_id>\d+)/print$',
'print_assignment',
name='print_assignment',
),
url(r'^(?P<assignment_id>\d+)/gen_poll$',
'gen_poll',
name='assignment_gen_poll',
),
url(r'^poll/(?P<poll_id>\d+)$',
ViewPoll.as_view(),
name='assignment_poll_view',
),
url(r'^poll/(?P<poll_id>\d+)/del$',
'delete_poll',
name='assignment_poll_delete',
),
url(r'^poll/(?P<poll_id>\d+)/pub/$',
'set_published',
{'published': True},
name='assignment_poll_publish',
),
url(r'^poll/(?P<poll_id>\d+)/notpub/$',
'set_published',
{'published': False},
name='assignment_poll_notpublish',
),
url(r'^(?P<assignment_id>\d+)/elected/(?P<profile_id>\d+)$',
'set_elected',
{'elected': True},
name='assignment_user_elected',
),
url(r'^(?P<assignment_id>\d+)/notelected/(?P<profile_id>\d+)$',
'set_elected',
{'elected': False},
name='assignment_user_not_elected',
),
)

View File

@ -14,35 +14,103 @@ from django.conf.urls.defaults import *
from django.core.urlresolvers import reverse
urlpatterns = patterns('participant.views',
url(r'^participant/$', 'get_overview', name='user_overview'),
url(r'^participant/new$', 'edit', name='user_new'),
url(r'^participant/(?P<user_id>\d+)/edit$', 'edit', name='user_edit'),
url(r'^participant/print$', 'print_userlist', name='user_print'),
url(r'^participant/(?P<user_id>\d+)/del$', 'user_delete', name='user_delete'),
url(r'^participant/(?P<user_id>\d+)/active/$', 'user_set_active', {'active': True}, name='user_active'),
url(r'^participant/(?P<user_id>\d+)/inactive/$', 'user_set_active', {'active': False}, name='user_inactive'),
url(r'^participant/(?P<user_id>\d+)/superuser/$', 'user_set_superuser', {'superuser': True}, name='user_superuser'),
url(r'^participant/(?P<user_id>\d+)/normaluser/$', 'user_set_superuser', {'superuser': False}, name='user_normaluser'),
url(r'^$',
'get_overview',
name='user_overview',
),
url(r'^participant/import$', 'user_import', name='user_import'),
url(r'^participant/group/$', 'get_group_overview', name='user_group_overview'),
url(r'^participant/group/new$', 'group_edit', name='user_group_new'),
url(r'^participant/group/(?P<group_id>\d+)/edit$', 'group_edit', name='user_group_edit'),
url(r'^participant/group/(?P<group_id>\d+)/del$', 'group_delete', name='user_group_delete'),
url(r'^user/settings$', 'user_settings', name='user_settings'),
url(r'^participant/resetpassword/(?P<user_id>\d+)$', 'reset_password', name='user_reset_password'),
url(r'^participant/passwords/print$', 'print_passwords', name='print_passwords'),
url(r'^new$',
'edit',
name='user_new',
),
url(r'^(?P<user_id>\d+)/edit$',
'edit',
name='user_edit',
),
url(r'^print$',
'print_userlist',
name='user_print',
),
url(r'^(?P<user_id>\d+)/del$',
'user_delete',
name='user_delete',
),
url(r'^(?P<user_id>\d+)/active/$',
'user_set_active',
{'active': True},
name='user_active',
),
url(r'^(?P<user_id>\d+)/inactive/$',
'user_set_active',
{'active': False},
name='user_inactive',
),
url(r'^(?P<user_id>\d+)/superuser/$',
'user_set_superuser',
{'superuser': True},
name='user_superuser',
),
url(r'^(?P<user_id>\d+)/normaluser/$',
'user_set_superuser',
{'superuser': False},
name='user_normaluser',
),
url(r'^import$',
'user_import',
name='user_import',
),
url(r'^group/$',
'get_group_overview',
name='user_group_overview',
),
url(r'^group/new$',
'group_edit',
name='user_group_new',
),
url(r'^group/(?P<group_id>\d+)/edit$',
'group_edit',
name='user_group_edit',
),
url(r'^group/(?P<group_id>\d+)/del$',
'group_delete',
name='user_group_delete',
),
url(r'^user/settings$',
'user_settings',
name='user_settings',
),
url(r'^resetpassword/(?P<user_id>\d+)$',
'reset_password',
name='user_reset_password',
),
url(r'^passwords/print$',
'print_passwords',
name='print_passwords',
),
)
urlpatterns += patterns('django.contrib.auth.views',
url(
r'^login/$',
url(r'^login/$',
'login',
{'template_name': 'participant/login.html'},
name='user_login',
),
url(
r'^logout/$',
url(r'^logout/$',
'logout_then_login',
name='user_logout',
)

View File

@ -26,9 +26,9 @@ urlpatterns = patterns('',
)),
(r'^agenda/', include('agenda.urls')),
(r'', include('application.urls')),
(r'', include('participant.urls')),
(r'', include('assignment.urls')),
(r'^application/', include('application.urls')),
(r'^assignment/', include('assignment.urls')),
(r'^participant/', include('participant.urls')),
(r'config/', include('system.urls')),
(r'projector/', include('projector.urls')),
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}),

View File

@ -35,7 +35,6 @@ from reportlab.pdfbase.ttfonts import TTFont
from openslides.agenda.models import Item
from openslides.application.models import Application
from openslides.assignment.models import Assignment
#from openslides.poll.models import Poll, Option
from openslides.participant.models import Profile
from system import config
from openslides.settings import SITE_ROOT
@ -297,180 +296,6 @@ def print_passwords(request):
return response
def get_application(application, story):
# application number
if application.number:
story.append(Paragraph(_("Application No.")+" %s" % application.number, stylesheet['Heading1']))
else:
story.append(Paragraph(_("Application No."), stylesheet['Heading1']))
# submitter
cell1a = []
cell1a.append(Spacer(0,0.2*cm))
cell1a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Submitter"), stylesheet['Heading4']))
cell1b = []
cell1b.append(Spacer(0,0.2*cm))
if application.status == "pub":
cell1b.append(Paragraph("__________________________________________",stylesheet['Signaturefield']))
cell1b.append(Spacer(0,0.1*cm))
cell1b.append(Paragraph("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+unicode(application.submitter.profile), stylesheet['Small']))
cell1b.append(Spacer(0,0.2*cm))
else:
cell1b.append(Paragraph(unicode(application.submitter.profile), stylesheet['Normal']))
# supporters
cell2a = []
cell2a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font><seqreset id='counter'>" % _("Supporters"), stylesheet['Heading4']))
cell2b = []
for s in application.supporter.all():
cell2b.append(Paragraph("<seq id='counter'/>.&nbsp; %s" % unicode(s.profile), stylesheet['Signaturefield']))
if application.status == "pub":
for x in range(0,application.missing_supporters):
cell2b.append(Paragraph("<seq id='counter'/>.&nbsp; __________________________________________",stylesheet['Signaturefield']))
cell2b.append(Spacer(0,0.2*cm))
# status
note = ""
for n in application.notes:
note += "%s " % unicode(n)
cell3a = []
cell3a.append(Paragraph("<font name='Ubuntu-Bold'>%s:</font>" % _("Status"), stylesheet['Heading4']))
cell3b = []
if note != "":
if application.status == "pub":
cell3b.append(Paragraph(note, stylesheet['Normal']))
else:
cell3b.append(Paragraph("%s | %s" % (application.get_status_display(), note), stylesheet['Normal']))
else:
cell3b.append(Paragraph("%s" % application.get_status_display(), stylesheet['Normal']))
# table
data = []
data.append([cell1a,cell1b])
data.append([cell2a,cell2b])
data.append([cell3a,cell3b])
# 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])
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))
# title
story.append(Paragraph(application.title, stylesheet['Heading3']))
# 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']))
return story
@permission_required('application.can_see_application')
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)
doc.title = None
story = []
if application_id is None: #print all applications
title = config["application_pdf_title"]
story.append(Paragraph(title, stylesheet['Heading1']))
preamble = config["application_pdf_preamble"]
if 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'):
if application.number:
story.append(Paragraph(_("Application No.")+" %s: %s" % (application.number, application.title), stylesheet['Heading3']))
else:
story.append(Paragraph(_("Application No.")+"&nbsp;&nbsp;&nbsp;: %s" % (application.title), stylesheet['Heading3']))
# Applications details (each application on single page)
for application in Application.objects.order_by('number'):
story.append(PageBreak())
story = get_application(application, story)
else: # print selected application
application = Application.objects.get(id=application_id)
if application.number:
number = application.number
else:
number = ""
filename = u'filename=%s%s.pdf;' % (_("Application"), str(number))
response['Content-Disposition'] = filename.encode('utf-8')
story = get_application(application, story)
doc.build(story, onFirstPage=firstPage, onLaterPages=firstPage)
return response
@permission_required('application.can_manage_application')
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)]
imgpath = os.path.join(SITE_ROOT, 'static/images/circle.png')
circle = "<img src='%s' width='15' height='15'/>&nbsp;&nbsp;" % imgpath
cell = []
cell.append(Spacer(0,0.8*cm))
cell.append(Paragraph(_("Application No.")+" "+str(poll.application.number), stylesheet['Ballot_title']))
cell.append(Paragraph(poll.application.title, stylesheet['Ballot_subtitle']))
cell.append(Paragraph(str(poll.ballot)+". "+_("Vote"), stylesheet['Ballot_description']))
cell.append(Spacer(0,0.5*cm))
cell.append(Paragraph(circle+_("Yes"), stylesheet['Ballot_option']))
cell.append(Paragraph(circle+_("No"), stylesheet['Ballot_option']))
cell.append(Paragraph(circle+_("Abstention"), stylesheet['Ballot_option']))
data= []
number = 1
# get ballot papers config values
ballot_papers_selection = config["application_pdf_ballot_papers_selection"]
ballot_papers_number = config["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])
rest = number % 2
if rest:
data.append([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
def get_assignment_votes(assignment):
votes = []
for candidate in assignment.candidates:

View File

@ -1,3 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
openslides.utils.views
~~~~~~~~~~~~~~~~~~~~~~
Views for utils.
:copyright: 2011 by the OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
try:
import json
except ImportError:
@ -192,6 +204,10 @@ class DeleteView(RedirectView, SingleObjectMixin):
class PDFView(PermissionMixin, View):
filename = 'No_Name'
top_space = 3
def get_top_space(self):
return self.top_space
def render_to_response(self, filename):
response = HttpResponse(mimetype='application/pdf')
@ -200,7 +216,7 @@ class PDFView(PermissionMixin, View):
buffer = StringIO()
pdf_document = SimpleDocTemplate(buffer)
story = [Spacer(1,3*cm)]
story = [Spacer(1, self.get_top_space()*cm)]
self.append_to_pdf(story)