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, data, file):
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 data["basisbeitrag"]:
24 config.setConfig("beitrag_basis", data["basisbeitrag"])
26 if data["zusatzbeitrag"]:
27 config.setConfig("beitrag_zusatz", data["zusatzbeitrag"])
29 def erstelle_ehmeldung(data):
30 from PyPDF2 import PdfFileWriter, PdfFileReader
31 from datetime import date
33 from reportlab.pdfgen import canvas
34 from reportlab.lib.pagesizes import letter
37 can = canvas.Canvas(packet, pagesize=letter)
40 can.setFont("Helvetica", 14)
41 can.drawString(80, 770, "Siedlervereinigung Berg am Laim")
42 can.setFont("Helvetica", 12)
43 can.drawString(205, 618, data["VorZuname"])
44 can.drawString(205, 600, data["VorZunamePartner"])
45 can.drawString(205, 583, data["Wohnanschrift"])
46 can.drawString(205, 566, data["Telefon"])
47 can.drawString(365, 566, data["Email"])
48 can.drawString(205, 549, data["Geburtsdatum"])
49 versichertes_object = data["VersichertesObjekt"]
50 if versichertes_object == "":
51 versichertes_object = data["Wohnanschrift"]
52 can.drawString(205, 500, versichertes_object)
53 can.drawString(193, 466, str(data["AnzahlWohnungen"]))
54 if data["Selbstgenutzt"]:
55 can.drawString(360, 466, "X")
56 if data["Eigentumswohnung"]:
57 can.drawString(192, 449, "X")
58 if data["Gewerblich"]:
59 can.drawString(360, 449, "X")
60 can.drawString(140, 376, date.today().strftime('%d.%m.%Y'))
61 can.drawString(350, 376, "Maschinell erstellt.")
65 #move to the beginning of the StringIO buffer
68 # create a new PDF with Reportlab
69 new_pdf = PdfFileReader(packet)
70 # read your existing PDF
71 existing_pdf = PdfFileReader(open("/home/sparky2021/SVBaL/Aktuell/BeitrittserklarungSVBaL.pdf", "rb"))
72 output = PdfFileWriter()
73 # add the "watermark" (which is the new pdf) on the existing page
74 page = existing_pdf.pages[0]
75 page.mergePage(new_pdf.pages[0])
77 # finally, write "output" to a real file
78 output_stream = open("meldung.pdf", "wb")
79 output.write(output_stream)
82 def pdfs_erstellen(request, verein):
83 from django.template import loader
86 cf = config.getInstance("svbal")
87 cf.setConfig("DataFile", "../../Test/etc/Export.csv")
88 from eh_app.qmodels import Mitglied
89 mm = Mitglied.objects.all()
90 template = loader.get_template("brief.tex")
92 from eh_app.AWK.pdf_ersteller import PdfErsteller
93 pe = PdfErsteller(request, template, "../../latex")