3 def handle_uploaded_file(csv_file):
4 csv_file_name = str(csv_file)
5 data_path = config.getInstance().requireConfig("data_path")
6 path = os.path.join(data_path, csv_file_name)
7 with open(path, 'wb+') as destination:
8 for chunk in csv_file.chunks():
9 destination.write(chunk)
11 def aktualisiere_config(config, data):
12 if data["briefpapier"]:
13 uploaded_file = data["briefpapier"]
14 data_path = config.requireConfig("data_path")
15 # copy briefpapier into data_path
16 with open(os.path.join(data_path, uploaded_file.name), 'wb+') as destination:
17 for chunk in uploaded_file.chunks():
18 destination.write(chunk)
19 config.set_config("briefpapier", uploaded_file.name)
21 if data["basisbeitrag"]:
22 config.set_config("beitrag_basis", data["basisbeitrag"])
24 if data["zusatzbeitrag"]:
25 config.set_config("beitrag_zusatz", data["zusatzbeitrag"])
27 def erstelle_ehmeldung(data):
28 from PyPDF2 import PdfFileWriter, PdfFileReader
29 from datetime import date
31 from reportlab.pdfgen import canvas
32 from reportlab.lib.pagesizes import letter
35 can = canvas.Canvas(packet, pagesize=letter)
38 can.setFont("Helvetica", 12)
39 can.drawString(205, 618, data["VorZuname"])
40 can.drawString(205, 600, data["VorZunamePartner"])
41 can.drawString(205, 583, data["Wohnanschrift"])
42 can.drawString(205, 566, data["Telefon"])
43 can.drawString(365, 566, data["Email"])
44 can.drawString(205, 549, data["Geburtsdatum"])
45 versichertes_object = data["VersichertesObjekt"]
46 if versichertes_object == "":
47 versichertes_object = data["Wohnanschrift"]
48 can.drawString(205, 500, versichertes_object)
49 can.drawString(193, 466, str(data["AnzahlWohnungen"]))
50 if data["Selbstgenutzt"]:
51 can.drawString(350, 466, "X")
52 if data["Eigentumswohnung"]:
53 can.drawString(188, 449, "X")
54 if data["Gewerblich"]:
55 can.drawString(350, 449, "X")
56 can.drawString(140, 376, date.today().strftime('%d.%m.%Y'))
57 can.drawString(350, 376, "Maschinell erstellt.")
61 #move to the beginning of the StringIO buffer
64 # create a new PDF with Reportlab
65 new_pdf = PdfFileReader(packet)
66 # read your existing PDF
67 existing_pdf = PdfFileReader(open("/home/sparky2021/SVBaL/Aktuell/BeitrittserklarungSVBaL.pdf", "rb"))
68 output = PdfFileWriter()
69 # add the "watermark" (which is the new pdf) on the existing page
70 page = existing_pdf.pages[0]
71 page.mergePage(new_pdf.pages[0])
73 # finally, write "output" to a real file
74 output_stream = open("meldung.pdf", "wb")
75 output.write(output_stream)