Skip to content

Commit

Permalink
amend context data in base view
Browse files Browse the repository at this point in the history
  • Loading branch information
jenriordan committed Jan 30, 2025
1 parent 20078dc commit c4be7cb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions django_app/core/base_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ class BaseDownloadPDFView(DetailView):
header = "Report a suspected breach"

def get(self, request: HttpRequest, **kwargs: object) -> HttpResponse:
context_data = self.get_context_data()
filename = f"report-{context_data['reference']}.pdf"
self.reference = self.request.GET.get("reference", "")
filename = f"report-{self.reference}.pdf"
pdf_data = None
template_string = render_to_string(self.template_name, context=context_data)
template_string = render_to_string(self.template_name, context=self.get_context_data(**kwargs))

with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=True)
Expand All @@ -130,6 +130,5 @@ def get(self, request: HttpRequest, **kwargs: object) -> HttpResponse:
def get_context_data(self, **kwargs: object) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
context["header"] = self.header
reference = self.request.GET.get("reference", "")
context["reference"] = reference
context["reference"] = self.reference
return context

0 comments on commit c4be7cb

Please sign in to comment.