2 from eh_app.AWK import config
4 def handle_uploaded_file(csv_file):
5 csv_file_name = str(csv_file)
6 data_path = config.getInstance().requireConfig("data_path")
7 path = os.path.join(data_path, csv_file_name)
8 with open(path, 'wb+') as destination:
9 for chunk in csv_file.chunks():
10 destination.write(chunk)
12 def aktualisiere_config(config, vorlagen_data, beitrag_data):
15 uploaded_file = file.name
16 data_path = config.requireConfig("data_path")
17 # copy briefpapier into data_path
18 with open(os.path.join(data_path, uploaded_file), 'wb+') as destination:
19 for chunk in file.chunks():
20 destination.write(chunk)
21 config.setConfig("briefpapier", uploaded_file)
23 if vorlagen_data["vorlage"]:
24 config.setConfig("vorlage", vorlagen_data["vorlage"])
25 if beitrag_data["basisbeitrag"]:
26 config.setConfig("beitrag_basis", beitrag_data["basisbeitrag"])
28 if beitrag_data["zusatzbeitrag"]:
29 config.setConfig("beitrag_zusatz", beitrag_data["zusatzbeitrag"])
31 def erstelle_ehmeldung(data):
32 from PyPDF2 import PdfFileWriter, PdfFileReader
33 from datetime import date
35 from reportlab.pdfgen import canvas
36 from reportlab.lib.pagesizes import letter
39 can = canvas.Canvas(packet, pagesize=letter)
42 can.setFont("Helvetica", 14)
43 can.drawString(80, 770, "Siedlervereinigung Berg am Laim")
44 can.setFont("Helvetica", 12)
45 can.drawString(205, 618, data["VorZuname"])
46 can.drawString(205, 600, data["VorZunamePartner"])
47 can.drawString(205, 583, data["Wohnanschrift"])
48 can.drawString(205, 566, data["Telefon"])
49 can.drawString(365, 566, data["Email"])
50 can.drawString(205, 549, data["Geburtsdatum"])
51 versichertes_object = data["VersichertesObjekt"]
52 if versichertes_object == "":
53 versichertes_object = data["Wohnanschrift"]
54 can.drawString(205, 500, versichertes_object)
55 can.drawString(193, 466, str(data["AnzahlWohnungen"]))
56 if data["Selbstgenutzt"]:
57 can.drawString(360, 466, "X")
58 if data["Eigentumswohnung"]:
59 can.drawString(192, 449, "X")
60 if data["Gewerblich"]:
61 can.drawString(360, 449, "X")
62 can.drawString(140, 376, date.today().strftime('%d.%m.%Y'))
63 can.drawString(350, 376, "Maschinell erstellt.")
67 #move to the beginning of the StringIO buffer
70 # create a new PDF with Reportlab
71 new_pdf = PdfFileReader(packet)
72 # read your existing PDF
73 existing_pdf = PdfFileReader(open("/home/sparky2021/SVBaL/Aktuell/BeitrittserklarungSVBaL.pdf", "rb"))
74 output = PdfFileWriter()
75 # add the "watermark" (which is the new pdf) on the existing page
76 page = existing_pdf.pages[0]
77 page.mergePage(new_pdf.pages[0])
79 # finally, write "output" to a real file
80 output_stream = open("meldung.pdf", "wb")
81 output.write(output_stream)
84 def pdfs_erstellen(request, verein):
85 from django.template import loader
88 cf = config.getInstance("svbal")
89 cf.setConfig("DataFile", "../../Test/etc/Export.csv")
90 from eh_app.qmodels import Mitglied
91 mm = Mitglied.objects.all()
92 template = loader.get_template("brief.tex")
94 from eh_app.AWK.pdf_ersteller import PdfErsteller
95 pe = PdfErsteller(request, template, "../../latex")