Skip to content
Snippets Groups Projects
Verified Commit ce2016aa authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Use PDF rendering tools from core

parent cd27bfc9
No related branches found
No related tags found
1 merge request!77Resolve "PDF export for timetables"
Pipeline #5518 failed
......@@ -18,6 +18,7 @@ from rules.contrib.views import permission_required
from aleksis.core.models import Announcement, Group, Person
from aleksis.core.util import messages
from aleksis.core.util.core_helpers import get_site_preferences, has_person
from aleksis.core.util.pdf import render_pdf
from .forms import LessonSubstitutionForm
from .managers import TimetableType
......@@ -195,17 +196,10 @@ def timetable(
if is_print:
template_name = "chronos/timetable_print.html"
template = get_template(template_name)
html_template = render_to_string(template_name, context).replace("/static", STATIC_ROOT)
f, path = mkstemp(".html")
print(path)
with open(path, "w") as f:
f.write(html_template)
f2, path2 = mkstemp(".pdf")
subprocess.run(["electron-pdf", path, path2])
file = open(path2, "rb")
return FileResponse(file, content_type="application/pdf")
context["back_url"] = reverse(
"timetable_by_week", args=[type_.value, pk, wanted_week.year, wanted_week.week],
)
return render_pdf(request, template_name, context)
else:
template_name = "chronos/timetable.html"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment