]> wagnertech.de Git - SVBaL.git/blobdiff - python/eh_util/eh_app/AWK/routines.py
Merge remote-tracking branch 'origin/kassenschreiben2025' into simon
[SVBaL.git] / python / eh_util / eh_app / AWK / routines.py
index 52509b70106b2b726c41078058e54a93801af969..4a98c0ebdae4e1faa59023bf2a509cdb84afedea 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,28 +9,23 @@ 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.setConfig("briefpapier", uploaded_file.name)
-    
+        config.setConfig("briefpapier", uploaded_file)
+
     if data["basisbeitrag"]:
         config.setConfig("beitrag_basis", data["basisbeitrag"])
-        
+
     if data["zusatzbeitrag"]:
         config.setConfig("beitrag_zusatz", data["zusatzbeitrag"])
     
-def erstellepdf(text):
-    with open(r'G:\SVBaL\python\eh_util\eh_app\test.tex', 'w') as f: # öffnet ein neues Dokument mit dem Namen test.tex
-        f.write(text) # schreibt in dieses neue Dokument
-        
-    # TODO: AUfruf PDF latex tex -> pdf
-
 def erstelle_ehmeldung(data):
     from PyPDF2 import PdfFileWriter, PdfFileReader
     from datetime import date
@@ -81,3 +77,20 @@ def erstelle_ehmeldung(data):
     output.write(output_stream)
     output_stream.close()
       
+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)
+