From e268d43580ea868b580aa2e60785958772b0a55b Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Wed, 24 Apr 2013 15:07:39 +0200 Subject: [PATCH] Fixed motion poll pdf (use correct delegates group, use template without header/footer) --- openslides/assignment/views.py | 1 - openslides/motion/pdf.py | 8 ++++++-- openslides/motion/views.py | 11 +++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index a4bee73c5..0dbeec68c 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -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" diff --git a/openslides/motion/pdf.py b/openslides/motion/pdf.py index a029b2b2f..344f81cde 100644 --- a/openslides/motion/pdf.py +++ b/openslides/motion/pdf.py @@ -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()) diff --git a/openslides/motion/views.py b/openslides/motion/views.py index 16374909a..811f90470 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -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.