From f8dcb4007263c0a93534f4e91582d4ebe1c255b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marike=20Vo=C3=9Fbeck?= Date: Fri, 6 Mar 2026 13:31:50 +0100 Subject: [PATCH] Setup PDF Template, changed views and employeeform to cater to it --- .../templates/austritt/employee_form.html | 6 +- austritt/templates/austritt/pdf_template.html | 164 ++++++++++++++++++ austritt/views.py | 48 ++++- 3 files changed, 213 insertions(+), 5 deletions(-) create mode 100644 austritt/templates/austritt/pdf_template.html diff --git a/austritt/templates/austritt/employee_form.html b/austritt/templates/austritt/employee_form.html index d6d448f..6c439f2 100644 --- a/austritt/templates/austritt/employee_form.html +++ b/austritt/templates/austritt/employee_form.html @@ -57,13 +57,13 @@ Veränderungsrelevante Angaben {% endif %} {% endif %} -{% if datatable == True %} +{% if datatable == 1 %} {% translate "Bestätigungsschritt" %} {% endif %}

- {% if datatable == True %} + {% if datatable == 1 %} {% for key, value in data.items %} @@ -96,7 +96,7 @@ {% if wizard.steps.prev %} {% endif %} - {% if datatable == True %} + {% if datatable == 1 %} {% else %} diff --git a/austritt/templates/austritt/pdf_template.html b/austritt/templates/austritt/pdf_template.html new file mode 100644 index 0000000..fde6647 --- /dev/null +++ b/austritt/templates/austritt/pdf_template.html @@ -0,0 +1,164 @@ +{% load i18n %} +{% load static %} + + + +{% if datatable == 2 %} + + + +

Übergabedokument von Arbeitsmitteln: {{ data.firstname }} {{ data.lastname }}

+

Handover sheet of work equipment:

+
{{ key }}{{ value }}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[X]Ausstattung/EquipmentWeitergabe an/Handover to

Laptop + Ladekabel {{% if data.laptop_id %}} {{data.laptop_id}} {{% else %}} ID nicht bekannt {{% endif %}}

IT

Home-Office Geräte (Monitor, Kabel, Tastatur, Maus)

IT
{{% if data.mobile=="JA" %}}

Mobiltelefon (ID nicht angegeben)

{{% else %}}

Mobiltelefon

{{% endif %}}
IT
{{% if data.credit_card=="JA" %}}

Kreditkarte

{{% else %}}

Kreditkarte

{{% endif %}}
{{% if data.sim=="JA" %}}

SIM Karte – bitte aushändigen lassen

{{% else %}}

SIM Karte

{{% endif %}}

Transponder Nr.

{{ data.transponder_id}}
Office

Rollcontainer-Schlüssel: Abgabe oder im Rollcontainer gelassen

Office
{{% if data.pension=="JA" %}}

MA hat BAV Unterlagen erhalten

{{% else %}}

MA hat BAV Unterlagen erhalten

{{% endif %}}
HR

Sonstiges: {{ data.miscenalleous }}

BVG-Firmenticket ist bei Austritt bis 23:59 Uhr des Monatsletzten gültig. + Es kann dann entsorgt werden.

+

BVG company ticket BVG company ticket is valid until 23:59 on the last day of the month. + It can then be discarded. +

+

+ + + + + + + + + + +
Sonstige Vereinbarungen/Other agreements +
{{% if data.bahncard=="JA" %}}BahnCard {{% else %}} BahnCard{{% endif %}} falls vorhanden, kann diese behalten werden, da sie ausläuft
+

+ + + + + + +

Rückgabe: Hiermit bestätige ich die vollständige Übergabe aller mir zur Verfügung gestellten Arbeitsmittel im gepflegten und funktionstüchtigen Zustand. Ich habe die Benutzung durch Dritte - sofern es sich nicht um betriebseigene Mitarbeitende handelt - nicht gestattet. Außerdem bestätige ich hiermit die vollumfängliche Zusicherung der Einhaltung der allgemeinen Vertraulichkeitserklärung/Datenschutzerklärung, sowie die Einhaltung der Verschwiegenheitsvereinbarung aus dem Arbeitsvertrag.

+

Handover: I hereby confirm the complete handover of all work equipment provided to me in a well-maintained and functional condition. I have not permitted the use by third parties - unless they are employees of Wikimedia. Furthermore, I hereby confirm the full assurance of compliance with the general confidentiality declaration/data protection declaration, as well as compliance with the confidentiality agreement from the employment contract.

+
+

+ + + + + + + + + + + + + + + + + + +
Berlin, ________________________________________________________________________
entgegengenommen vonUnterschrift ehem. Mitarbeitenden
received bySignature of leaving employee
+ +{% endif %} \ No newline at end of file diff --git a/austritt/views.py b/austritt/views.py index d6699a7..b0c2361 100644 --- a/austritt/views.py +++ b/austritt/views.py @@ -46,7 +46,7 @@ def change_process(wizard): class EvaFormView(LoginRequiredMixin, CookieWizardView): template_name = 'austritt/employee_form.html' - form_list = [PersonalForm, HRForm, ITForm, RestForm, DummyForm, DummyForm] + form_list = [PersonalForm, HRForm, ITForm, RestForm, DummyForm, DummyForm, DummyForm] instance = None choice = 'IN' @@ -91,7 +91,24 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): # deliver context for forms if we are in the last step if (self.steps.step1 == 5 or (self.choice != 'IN' and self.steps.step1 == 5)): context.update({'data': self.beautify_data(self.get_all_cleaned_data()), - 'datatable': True,}) + 'datatable': 1,}) + return context + + + def get_pdf_data(self, form, **kwargs): + '''this method is called to give context data to the template''' + + #print('GETCONTEXT') + context = super().get_pdf_data(form=form, **kwargs) + testmode = settings.DEBUG or settings.MAILTEST + context.update({'choice': self.choice, + 'choice_string': TYPE_CHOICES[self.choice], + 'TESTMODE': testmode}) + + # deliver context for forms if we are in the last step + if (self.steps.step1 == 6 or (self.choice != 'IN' and self.steps.step1 == 6)): + context.update({'data': self.beautify_data_pdf(self.get_all_cleaned_data()), + 'datatable': 2,}) return context def get_form_instance(self,step): @@ -214,3 +231,30 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView): newdata.update({k:'' for k,v in newdata.items() if v == []}) return newdata + + def beautify_data_pdf(self, data): + ''' # use long form for contextdata instead of short form if available + # + # ATTENTION! + # This implementation works only for unique keys over all of these dicts from model.py + # + ''' + # handling multiselect field for hardware beforehand + + hardware = data.get("hardware", []) + choices_dict = dict(self.form_class.base_fields["hardware"].choices) + selected_hardware = [choices_dict[val] for val in hardware] + + return { + "firstname": data.get("firstname"), + "lastname": data.get("lastname"), + "laptop_id": data.get("laptop_id"), + "hardware": ", ".join(selected_hardware), + "mobile": data.get("mobile"), + "credit_card": data.get("credit_card"), + "sim": data.get("sim"), + "transponder_id": data.get("transponder_id"), + "pension": data.get("pension"), + "miscellaneous": data.get("miscellaneous"), + "bahncard": data.get("bahncard"), + }