Merge pull request #2178 from normanjaeckel/FixMotionPDF
Fixed motion PDF if motions have no identifier. Fixed #2158.
This commit is contained in:
commit
28584c62f6
@ -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())
|
||||
|
28
tests/integration/motions/test_pdf.py
Normal file
28
tests/integration/motions/test_pdf.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user