Merge pull request #1276 from emanuelschuetze/fix-1275
Fixed #1275 (Creating assignment pdf failed)
This commit is contained in:
commit
dbb277cb85
@ -424,27 +424,36 @@ class AssignmentPDF(PDFView):
|
|||||||
data_votes.append(row)
|
data_votes.append(row)
|
||||||
|
|
||||||
# Add valid votes row
|
# Add valid votes row
|
||||||
if poll.votesvalid is not None:
|
footrow_one = []
|
||||||
footrow_one = []
|
footrow_one.append(_("Valid votes"))
|
||||||
footrow_one.append(_("Valid votes"))
|
votesvalid_is_used = False
|
||||||
for poll in polls:
|
for poll in polls:
|
||||||
footrow_one.append(poll.print_votesvalid())
|
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)
|
data_votes.append(footrow_one)
|
||||||
|
|
||||||
# Add invalid votes row
|
# Add invalid votes row
|
||||||
if poll.votesinvalid is not None:
|
footrow_two = []
|
||||||
footrow_two = []
|
footrow_two.append(_("Invalid votes"))
|
||||||
footrow_two.append(_("Invalid votes"))
|
votesinvalid_is_used = False
|
||||||
for poll in polls:
|
for poll in polls:
|
||||||
footrow_two.append(poll.print_votesinvalid())
|
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)
|
data_votes.append(footrow_two)
|
||||||
|
|
||||||
# Add votes cast row
|
# Add votes cast row
|
||||||
if poll.votescast is not None:
|
footrow_three = []
|
||||||
footrow_three = []
|
footrow_three.append(_("Votes cast"))
|
||||||
footrow_three.append(_("Votes cast"))
|
votescast_is_used = False
|
||||||
for poll in polls:
|
for poll in polls:
|
||||||
footrow_three.append(poll.print_votescast())
|
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)
|
data_votes.append(footrow_three)
|
||||||
|
|
||||||
table_votes = Table(data_votes)
|
table_votes = Table(data_votes)
|
||||||
|
22
tests/assignment/test_pdf.py
Normal file
22
tests/assignment/test_pdf.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user