]> wagnertech.de Git - SVBaL.git/blobdiff - python/eh_util/eh_app/AWK/routines.py
pydev-s6
[SVBaL.git] / python / eh_util / eh_app / AWK / routines.py
index f176462f27db85f3a48fb1b256d59f4027e2b55c..fffbfaa50962ec660ac72c9584364bf8b635ed2e 100644 (file)
@@ -1,4 +1,5 @@
 import os
+from eh_app.AWK import config
 '''
 def handle_uploaded_file(csv_file):
     csv_file_name = str(csv_file)
@@ -8,33 +9,36 @@ def handle_uploaded_file(csv_file):
         for chunk in csv_file.chunks():
             destination.write(chunk)
 '''
-def aktualisiere_config(config, data):
-    if data["briefpapier"]:
-        uploaded_file = data["briefpapier"]
+def aktualisiere_config(config, data, file):
+
+    if file:
+        uploaded_file = file.name
         data_path = config.requireConfig("data_path")
         # copy briefpapier into data_path
-        with open(os.path.join(data_path, uploaded_file.name), 'wb+') as destination:
-            for chunk in uploaded_file.chunks():
+        with open(os.path.join(data_path, uploaded_file), 'wb+') as destination:
+            for chunk in file.chunks():
                 destination.write(chunk)
-        config.set_config("briefpapier", uploaded_file.name)
-    
+        config.setConfig("briefpapier", uploaded_file)
+
     if data["basisbeitrag"]:
-        config.set_config("beitrag_basis", data["basisbeitrag"])
-        
-    if data["zusatzbeitrag"]:
-        config.set_config("beitrag_zusatz", data["zusatzbeitrag"])
+        config.setConfig("beitrag_basis", data["basisbeitrag"])
 
+    if data["zusatzbeitrag"]:
+        config.setConfig("beitrag_zusatz", data["zusatzbeitrag"])
+    
 def erstelle_ehmeldung(data):
     from PyPDF2 import PdfFileWriter, PdfFileReader
     from datetime import date
     import io
     from reportlab.pdfgen import canvas
     from reportlab.lib.pagesizes import letter
-    
+   
     packet = io.BytesIO()
     can = canvas.Canvas(packet, pagesize=letter)
     
     # Adressfeld
+    can.setFont("Helvetica", 14)
+    can.drawString(80, 770, "Siedlervereinigung Berg am Laim")
     can.setFont("Helvetica", 12)
     can.drawString(205, 618, data["VorZuname"])
     can.drawString(205, 600, data["VorZunamePartner"])
@@ -48,11 +52,11 @@ def erstelle_ehmeldung(data):
     can.drawString(205, 500, versichertes_object)
     can.drawString(193, 466, str(data["AnzahlWohnungen"]))
     if data["Selbstgenutzt"]:
-        can.drawString(350, 466, "X")
+        can.drawString(360, 466, "X")
     if data["Eigentumswohnung"]:
-        can.drawString(188, 449, "X")
+        can.drawString(192, 449, "X")
     if data["Gewerblich"]:
-        can.drawString(350, 449, "X")
+        can.drawString(360, 449, "X")
     can.drawString(140, 376, date.today().strftime('%d.%m.%Y'))
     can.drawString(350, 376, "Maschinell erstellt.")
         
@@ -74,4 +78,21 @@ def erstelle_ehmeldung(data):
     output_stream = open("meldung.pdf", "wb")
     output.write(output_stream)
     output_stream.close()
-      
\ No newline at end of file
+      
+def pdfs_erstellen(request, verein):
+    from django.template import loader
+    
+    # lese alle Miglieder
+    cf = config.getInstance("svbal")
+    cf.setConfig("DataFile", "../../Test/etc/Export.csv")
+    from eh_app.qmodels import Mitglied
+    mm = Mitglied.objects.all()
+    template = loader.get_template("brief.tex")
+    
+    from eh_app.AWK.pdf_ersteller import PdfErsteller
+    pe = PdfErsteller(request, template, "../../latex")
+    
+    # Erstelle PDFs
+    for m in mm:
+        pe.erstellepdf(m)
+