diff --git a/openslides/motions/pdf.py b/openslides/motions/pdf.py index bf15915bd..744509e64 100644 --- a/openslides/motions/pdf.py +++ b/openslides/motions/pdf.py @@ -1,7 +1,6 @@ import random import re from html import escape -from operator import attrgetter from bs4 import BeautifulSoup from django.conf import settings @@ -22,7 +21,7 @@ def motions_to_pdf(pdf, motions): """ Create a PDF with all motions. """ - motions = natsorted(motions, key=attrgetter('identifier')) + motions = natsorted(motions, key=lambda motion: motion.identifier or '') all_motion_cover(pdf, motions) for motion in motions: pdf.append(PageBreak()) diff --git a/tests/integration/motions/test_pdf.py b/tests/integration/motions/test_pdf.py new file mode 100644 index 000000000..87c3ffd11 --- /dev/null +++ b/tests/integration/motions/test_pdf.py @@ -0,0 +1,28 @@ +from django.core.urlresolvers import reverse +from rest_framework import status + +from openslides.core.config import config +from openslides.motions.models import Motion +from openslides.utils.test import TestCase + + +class AllMotionPDF(TestCase): + """ + Tests creating a PDF of all motions. + """ + def setUp(self): + self.client.login(username='admin', password='admin') + config['motions_identifier'] = 'manually' + self.motion = Motion( + title='test_title_Dik4jaey5ku6axee7Dai', + text='test_text_Auvie4euf2oang8ahcie') + self.motion.save() + self.motion2 = Motion( + title='test_title_AeTheech6euf9siM8uey', + text='test_text_Cohsh2egaexae8eebiot', + identifier='42') + self.motion2.save() + + def test_pdf_all_motions(self): + response = self.client.get(reverse('motions_pdf')) + self.assertEqual(response.status_code, status.HTTP_200_OK)