From 2ba675c1b6d762a9587a6614a8ce39f150acf0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Fri, 5 Feb 2016 21:22:47 +0100 Subject: [PATCH] Fixed assignment PDF. Fixed #1940. --- openslides/assignments/views.py | 6 ++--- tests/integration/assignments/test_views.py | 25 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/integration/assignments/test_views.py diff --git a/openslides/assignments/views.py b/openslides/assignments/views.py index f24d805a5..f6463dea0 100644 --- a/openslides/assignments/views.py +++ b/openslides/assignments/views.py @@ -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: diff --git a/tests/integration/assignments/test_views.py b/tests/integration/assignments/test_views.py new file mode 100644 index 000000000..a23775fcf --- /dev/null +++ b/tests/integration/assignments/test_views.py @@ -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)