Content:
diff --git a/core/templates/report_template/weekly.html b/core/templates/report_template/weekly.html
new file mode 100644
index 0000000..6c05a5c
--- /dev/null
+++ b/core/templates/report_template/weekly.html
@@ -0,0 +1,2464 @@
+{% load markdown %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+ Name: {{ user }}
+ |
+
+ Ausbildungsnachweis Nr. {{ num }}
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+ Ausbildungsjahr: {{ year }}
+ |
+
+
+
+ Firma:
+ |
+
+ Ausbildungsabteilung: {{ department }}
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+ CANCOM GmbH
+ |
+
+
+ |
+
+ Woche: {{ week }}
+ |
+
+
+
+ Messerschmittstr. 20
+ |
+
+
+ |
+
+
+ |
+
+
+
+ 89343 Jettingen-Scheppach
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+ vom: {{ start_date }} bis: {{ end_date }}
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+ Betriebliche
+ Tätigkeit (bitte
+ Ausbildungsverlauf mit der zeitlichen und sachlichen Gliederung abgleichen):
+
+
+ {{ company_text|markdown|safe }}
+
+
+
+ |
+
+ Stunden
+ |
+
+
+
+ Thema der Woche:
+ {{ week_topic|markdown|safe }}
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+ Berufsschule (Themen des
+ Unterrichts)
+
+ {{ school_text|markdown|safe }}
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+
+
+ |
+
+ 8
+ |
+
+
+
+ Gesamtstunden
+ |
+
+ 40
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+ Für
+ die
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+ Richtigkeit
+ |
+
+ ____________________
+ |
+
+ ____________________
+ |
+
+ ____________________
+ |
+
+ ____________________
+ |
+
+
+
+
+ |
+
+ Datum
+ |
+
+ Auszubildender
+ |
+
+ Datum
+ |
+
+ Ausbilder
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/urls.py b/core/urls.py
index dcab3cb..4e7c018 100644
--- a/core/urls.py
+++ b/core/urls.py
@@ -5,6 +5,9 @@ urlpatterns = [
path("", views.index, name="index"),
path("write", views.write_new_report, name="write"),
path("report/
", views.report_detail_page, name="report_detail"),
+ path("report//pdf", views.report_pdf_route, name="report_pdf"),
+ path("report//html", views.report_html_route, name="report_html"),
+ path("report//png", views.report_png_route, name="report_png"),
path("reports", views.reports_list, name="reports_list"),
path("draft", views.report_draft_update, name="report_draft_update"),
path("settings", views.settings_page, name="settings"),
diff --git a/core/views.py b/core/views.py
index 6144704..a477744 100644
--- a/core/views.py
+++ b/core/views.py
@@ -9,6 +9,7 @@ from django.template.loader import render_to_string
from core.styles import STYLE
from .util import is_htmx_request, title, htmx_request
from .reports import choose_report_kind
+from .doc_gen import gen_doc_html, gen_doc_pdf, gen_doc_png
import datetime
import json
@@ -176,7 +177,7 @@ def report_detail_page(request, report_id):
return htmx_request(
request,
"report.html",
- {"report": report, "form": form},
+ {"report": report, "form": form, "STYLE": STYLE},
f"Berichtsheft {report.num}",
)
@@ -224,3 +225,45 @@ def settings_page(request):
{"user": user},
"Einstellungen",
)
+
+
+def report_pdf_route(request, report_id):
+ user = AzureUser(request)
+
+ report = get_object_or_404(Berichtsheft, id=report_id)
+ form = choose_report_kind(report.kind)
+
+ if report.user != user.id:
+ return HttpResponse("Nah", status=401)
+
+ pdf_buffer = gen_doc_pdf(report)
+ response = HttpResponse(pdf_buffer, content_type="application/pdf")
+ return response
+
+
+def report_html_route(request, report_id):
+ user = AzureUser(request)
+
+ report = get_object_or_404(Berichtsheft, id=report_id)
+ form = choose_report_kind(report.kind)
+
+ if report.user != user.id:
+ return HttpResponse("Nah", status=401)
+
+ html = gen_doc_html(report)
+ response = HttpResponse(html)
+ return response
+
+
+def report_png_route(request, report_id):
+ user = AzureUser(request)
+
+ report = get_object_or_404(Berichtsheft, id=report_id)
+ form = choose_report_kind(report.kind)
+
+ if report.user != user.id:
+ return HttpResponse("Nah", status=401)
+
+ png = gen_doc_png(report)
+ response = HttpResponse(png, content_type="image/png")
+ return response
diff --git a/requirements.txt b/requirements.txt
index d8344af..5b5aab3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,4 +2,6 @@ Django~=4.2.11
psycopg2
markdown
bleach
-pillow
\ No newline at end of file
+pillow
+weasyprint
+pdf2image
\ No newline at end of file