From e796fcbc844d4a5d1478a2007ffedc51a9abd34d Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Wed, 29 Jun 2022 15:04:15 +0200 Subject: [PATCH] Fix fifpl pdf : https://trackers.pilotsystems.net/prebarreau/0487#i1 --- .../seminar_testimonial_payback.html | 97 ++++++++++--------- teleforma/views/pro.py | 6 +- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/teleforma/templates/teleforma/seminar_testimonial_payback.html b/teleforma/templates/teleforma/seminar_testimonial_payback.html index eef3d016..6e507107 100644 --- a/teleforma/templates/teleforma/seminar_testimonial_payback.html +++ b/teleforma/templates/teleforma/seminar_testimonial_payback.html @@ -16,92 +16,95 @@ {% endblock %} @@ -109,7 +112,7 @@ - + {% block layout %}
diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index 077549f5..91d4b7af 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -86,7 +86,7 @@ def content_to_pdf(content, dest, encoding='utf-8', **kwargs): """ src = weasyprint.HTML(string=content.encode(encoding), encoding=encoding) site = Site.objects.get_current() - src.write_pdf(dest, stylesheets=[f'https://{site.domain}/{settings.STATIC_URL}teleforma/css/teleforma_pdf.css',]) + src.write_pdf(dest, stylesheets=[f'https://{site.domain}{settings.STATIC_URL}teleforma/css/teleforma_pdf.css',]) return True @@ -767,7 +767,7 @@ class PDFTemplateResponseMixin(TemplateResponseMixin): Return the pdf attachment filename. If the filename is None, the pdf will not be an attachment. """ - return str(self.pdf_filename) + return self.pdf_filename and str(self.pdf_filename) or "pb.pdf" def get_pdf_url(self): """ @@ -807,6 +807,7 @@ class TestimonialView(PDFTemplateResponseMixin, SeminarView): model = Seminar template_name = 'teleforma/seminar_testimonial.html' pdf_template_name = template_name + pdf_filename = 'testimonial.pdf' def get_context_data(self, **kwargs): context = super(TestimonialView, self).get_context_data(**kwargs) @@ -924,6 +925,7 @@ class TestimonialPaybackView(TestimonialView): context['answers'] = Answer.objects.filter(question__in=seminar.question.all(), user=self.request.user, validated=True).order_by('question__rank') + context['site'] = Site.objects.get_current() # user_timer = get_seminar_timer(self.request.user, seminar) # context['user_timer'] = user_timer.days * 24 + user_timer.seconds / 3600 return context -- 2.39.5