Fixed assignment PDF. Fixed #1940.

This commit is contained in:
Norman Jäckel 2016-02-05 21:22:47 +01:00
parent 773ce0537d
commit 2ba675c1b6
2 changed files with 28 additions and 3 deletions

View File

@ -336,13 +336,13 @@ class AssignmentPDF(PDFView):
# Add result rows
elected_candidates = list(assignment.elected)
length = len(vote_results)
for candidate, poll_list in vote_results.iteritems():
for candidate, poll_list in vote_results.items():
row = []
candidate_string = candidate.get_short_name()
if candidate in elected_candidates:
candidate_string = "* " + candidate_string
if candidate.name_suffix and length < 20:
candidate_string += "\n(%s)" % candidate.name_suffix
if candidate.structure_level and length < 20:
candidate_string += "\n(%s)" % candidate.structure_level
row.append(candidate_string)
for vote in poll_list:
if vote is None:

View File

@ -0,0 +1,25 @@
from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
from rest_framework import status
from rest_framework.test import APIClient
from openslides.assignments.models import Assignment
from openslides.utils.test import TestCase
class PDF(TestCase):
"""
Tests assignment PDF.
"""
def setUp(self):
self.client = APIClient()
self.client.login(username='admin', password='admin')
self.admin = get_user_model().objects.get(username='admin')
self.assignment = Assignment.objects.create(title='test_assignment_OxieG7BioChahteY4aeM', open_posts=1)
def test_pdf_with_ballot(self):
self.assignment.set_candidate(self.admin)
self.assignment.create_poll()
self.assignment.polls.all()[0].set_published(True)
response = self.client.get(reverse('assignments_pdf'))
self.assertEqual(response.status_code, status.HTTP_200_OK)