Fixed motion poll pdf (use correct delegates group, use template without header/footer)

This commit is contained in:
Emanuel Schuetze 2013-04-24 15:07:39 +02:00
parent 5071daa148
commit e268d43580
3 changed files with 17 additions and 3 deletions

View File

@ -569,7 +569,6 @@ class AssignmentPollPDF(PDFView):
number = User.objects.filter(groups__pk=3).count()
except Group.DoesNotExist:
number = 0
elif ballot_papers_selection == "NUMBER_OF_ALL_PARTICIPANTS":
number = int(User.objects.count())
else: # ballot_papers_selection == "CUSTOM_NUMBER"

View File

@ -27,7 +27,7 @@ from .models import Motion
# Needed to count the delegates
# TODO: find another way to do this.
from openslides.participant.models import User
from openslides.participant.models import User, Group
def motions_to_pdf(pdf):
@ -277,7 +277,11 @@ def motion_poll_to_pdf(pdf, poll):
# set number of ballot papers
if ballot_papers_selection == "NUMBER_OF_DELEGATES":
# TODO: get this number from persons
number = User.objects.filter(type__iexact="delegate").count()
try:
if Group.objects.get(pk=3):
number = User.objects.filter(groups__pk=3).count()
except Group.DoesNotExist:
number = 0
elif ballot_papers_selection == "NUMBER_OF_ALL_PARTICIPANTS":
# TODO: get the number from the persons
number = int(User.objects.count())

View File

@ -20,6 +20,8 @@ from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop
from django.views.generic.detail import SingleObjectMixin
from django.http import Http404
from reportlab.platypus import SimpleDocTemplate
from openslides.utils.pdf import stylesheet
from openslides.utils.views import (
TemplateView, RedirectView, UpdateView, CreateView, DeleteView, PDFView,
@ -511,6 +513,7 @@ class PollPDFView(PollMixin, PDFView):
"""
permission_required = 'motion.can_manage_motion'
top_space = 0
def get(self, *args, **kwargs):
self.object = self.get_object()
@ -522,6 +525,14 @@ class PollPDFView(PollMixin, PDFView):
"""
return u'%s%s_%s' % (_("Motion"), str(self.object.poll_number), _("Poll"))
def get_template(self, buffer):
return SimpleDocTemplate(
buffer, topMargin=-6, bottomMargin=-6, leftMargin=0, rightMargin=0,
showBoundary=False)
def build_document(self, pdf_document, story):
pdf_document.build(story)
def append_to_pdf(self, pdf):
"""
Append PDF objects.