Skip to content

Commit

Permalink
refactor: Delete PDFCreateView.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-AP committed Aug 29, 2023
1 parent 437a27c commit f883ed4
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions digital_meal/views.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
from io import BytesIO

import pandas as pd
import requests

from django.conf import settings
from django.http import HttpResponse
from django.template.loader import get_template
from django.views.generic import TemplateView

from digital_meal.utils import yt_data, yt_plots, fitbit_plots

from xhtml2pdf import pisa


class IndividualReport(TemplateView):
""" Generates an individual report. """
Expand Down Expand Up @@ -196,20 +190,6 @@ def get_context_data(self, **kwargs):
return context


# TODO: Finish this view.
class IndividualReportPDF(IndividualReport):

def get(self, request, *args, **kwargs):
template = get_template(self.template_name)
context = self.get_context_data()
html = template.render(context)
pdf = BytesIO()
pisa.pisaDocument(BytesIO(html.encode('ISO-8859-1')), pdf)
response = HttpResponse(pdf.getvalue(), content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename=individual_report.pdf'
return response


class ScientificaLandingView(TemplateView):
template_name = 'digital_meal/scientifica_landing.html'

Expand Down

0 comments on commit f883ed4

Please sign in to comment.