From 83cca59c7e3fdefadfd205234f24fb8a122cb9b8 Mon Sep 17 00:00:00 2001 From: alazo Date: Mon, 14 Aug 2017 07:43:21 +0200 Subject: [PATCH] periode_pdf_2 --- cms/views.py | 16 ++++++++++------ media/periode.pdf | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cms/views.py b/cms/views.py index b158a9d..43645e5 100644 --- a/cms/views.py +++ b/cms/views.py @@ -3,10 +3,12 @@ Created on 4 déc. 2012 @author: alzo """ +import os + from django.views.generic import ListView, TemplateView, DetailView from django.db.models import F, Sum from django.http import HttpResponse - +from django.conf import settings from reportlab.platypus import Paragraph, Spacer, Table, TableStyle, Preformatted from reportlab.lib.units import cm from reportlab.lib import colors @@ -269,10 +271,12 @@ class ModulePDF(DetailView): [preformatted_left('Responsable'), preformatted_right(m.processus.domaine.responsable.descr_pdf())], ] t = Table(data, colWidths=[2.5*cm, 10*cm]) - t.setStyle(TableStyle([ - ('ALIGN', (0, 0), (-1, -1), 'LEFT'), - ('VALIGN', (0, 0), (-1, -1), 'TOP'), - ('LEFTPADDING', (0, 0), (-1, -1), 0), ]) + t.setStyle( + TableStyle([ + ('ALIGN', (0, 0), (-1, -1), 'LEFT'), + ('VALIGN', (0, 0), (-1, -1), 'TOP'), + ('LEFTPADDING', (0, 0), (-1, -1), 0), ] + ) ) t.hAlign = 0 response.story.append(Spacer(0, 1*cm)) @@ -321,7 +325,7 @@ class PeriodePDFView(TemplateView): def render_to_response(self, context, **response_kwargs): context = get_context(context) - filename = 'media/periode.pdf' + filename = os.path.join(settings.MEDIA_ROOT, 'periode.pdf') pdf = PeriodPDF(filename) for semestre_id in range(1, 7): modules = context['sem{0}'.format(str(semestre_id))] diff --git a/media/periode.pdf b/media/periode.pdf index 7d95517..b6c013d 100644 --- a/media/periode.pdf +++ b/media/periode.pdf @@ -23,7 +23,7 @@ endobj << /Outlines 10 0 R /PageMode /UseNone /Pages 8 0 R /Type /Catalog >> endobj 7 0 obj -<< /Author (anonymous) /CreationDate (D:20170814072142-01'00') /Creator (ReportLab PDF Library - www.reportlab.com) /Keywords () /ModDate (D:20170814072142-01'00') /Producer (ReportLab PDF Library - www.reportlab.com) +<< /Author (anonymous) /CreationDate (D:20170814074017-01'00') /Creator (ReportLab PDF Library - www.reportlab.com) /Keywords () /ModDate (D:20170814074017-01'00') /Producer (ReportLab PDF Library - www.reportlab.com) /Subject (unspecified) /Title (untitled) /Trapped /False >> endobj 8 0 obj @@ -243,7 +243,7 @@ xref trailer << /ID % ReportLab generated PDF document -- digest (http://www.reportlab.com) - [(\240o\267o\321\233L:\251\3545\212P1\275h) (\240o\267o\321\233L:\251\3545\212P1\275h)] + [(\353\211\003\306uO\376\265\357\030\317\244\200\211\306w) (\353\211\003\306uO\376\265\357\030\317\244\200\211\306w)] /Info 7 0 R /Root 6 0 R /Size 11 >> startxref 98675