Merge pull request #1276 from emanuelschuetze/fix-1275

Fixed #1275 (Creating assignment pdf failed)
This commit is contained in:
Oskar Hahn 2014-05-15 15:45:53 +02:00
commit dbb277cb85
2 changed files with 46 additions and 15 deletions

View File

@ -424,27 +424,36 @@ class AssignmentPDF(PDFView):
data_votes.append(row)
# Add valid votes row
if poll.votesvalid is not None:
footrow_one = []
footrow_one.append(_("Valid votes"))
votesvalid_is_used = False
for poll in polls:
footrow_one.append(poll.print_votesvalid())
if poll.votesvalid is not None:
votesvalid_is_used = True
if votesvalid_is_used:
data_votes.append(footrow_one)
# Add invalid votes row
if poll.votesinvalid is not None:
footrow_two = []
footrow_two.append(_("Invalid votes"))
votesinvalid_is_used = False
for poll in polls:
footrow_two.append(poll.print_votesinvalid())
if poll.votesinvalid is not None:
votesinvalid_is_used = True
if votesinvalid_is_used:
data_votes.append(footrow_two)
# Add votes cast row
if poll.votescast is not None:
footrow_three = []
footrow_three.append(_("Votes cast"))
votescast_is_used = False
for poll in polls:
footrow_three.append(poll.print_votescast())
if poll.votescast is not None:
votescast_is_used = True
if votescast_is_used:
data_votes.append(footrow_three)
table_votes = Table(data_votes)

View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from django.test.client import Client
from openslides.assignment.models import Assignment
from openslides.participant.models import User
from openslides.utils.test import TestCase
class AssignmentPDFTest(TestCase):
"""
Tests for assignment PDF.
"""
def setUp(self):
# Admin
self.admin = User.objects.get(pk=1)
self.admin_client = Client()
self.admin_client.login(username='admin', password='admin')
def test_render_pdf(self):
Assignment.objects.create(name='assignment_name_ith8qua1Eiferoqu5ju2', description="test", posts=1)
response = self.admin_client.get('/assignment/print/')
self.assertEqual(response.status_code, 200)