From 6763f371d4cdd040fd3f2ba9511835a87f91b0db Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 28 May 2015 22:41:02 +0100 Subject: [PATCH] Workaround for context bug --- RIGS/rigboard.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 9a06abe1..050e0eda 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -90,20 +90,24 @@ class EventPrint(generic.View): object = get_object_or_404(models.Event, pk=pk) template = get_template('RIGS/event_print.xml') copies = ('TEC', 'Client') - context = RequestContext(request, { - 'object': object, - 'fonts': { - 'opensans': { - 'regular': 'RIGS/static/fonts/OPENSANS-REGULAR.TTF', - 'bold': 'RIGS/static/fonts/OPENSANS-BOLD.TTF', - } - }, - }) merger = PdfFileMerger() for copy in copies: - context['copy'] = copy + + context = RequestContext(request, { # this should be outside the loop, but bug in 1.8.2 prevents this + 'object': object, + 'fonts': { + 'opensans': { + 'regular': 'RIGS/static/fonts/OPENSANS-REGULAR.TTF', + 'bold': 'RIGS/static/fonts/OPENSANS-BOLD.TTF', + } + }, + 'copy':copy + }) + + # context['copy'] = copy # this is the way to do it once we upgrade to Django 1.8.3 + rml = template.render(context) buffer = StringIO.StringIO()