Created
January 13, 2018 20:35
-
-
Save bencleary/f6dba3d29db2bb10335b1bb6b680555a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.views.generic.base import View | |
| from django.http import HttpResponse | |
| from .render import Render | |
| class RenderPDF(Render): | |
| params: dict = None | |
| template: str = None | |
| email: bool = False | |
| to: str = None | |
| class RenderPDFMixin(RenderPDF, View): | |
| def get(self, request, *args, **kwargs): | |
| if self.email is False: | |
| ### always add request object ### | |
| self.params['request'] = request | |
| return Render.render(self.template, self.params) | |
| else: | |
| ### process email #### | |
| return HttpResponse("Email") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.utils import timezone | |
| from .models import * | |
| from .mixins import RenderPDFMixin | |
| class Pdf(RenderPDFMixin): | |
| template = "pdf.html" | |
| params = { | |
| 'today': timezone.now(), | |
| 'sales': Sales.objects.all(), | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment