pydev-s6
authorMichael Wagner <michael@wagnertech.de>
Sat, 9 Nov 2024 22:04:47 +0000 (23:04 +0100)
committerMichael Wagner <michael@wagnertech.de>
Sat, 9 Nov 2024 22:04:47 +0000 (23:04 +0100)
python/eh_util/eh_app/AWK/config.py [new file with mode: 0644]
python/eh_util/eh_app/AWK/routines.py [new file with mode: 0644]
python/eh_util/eh_app/migrations/0001_initial.py [new file with mode: 0644]
python/eh_util/eh_app/migrations/__init__.py [new file with mode: 0644]
python/eh_util/eh_app/templates/__init__.py [new file with mode: 0644]
python/eh_util/eh_app/templates/kassenbrief.html [new file with mode: 0644]

diff --git a/python/eh_util/eh_app/AWK/config.py b/python/eh_util/eh_app/AWK/config.py
new file mode 100644 (file)
index 0000000..47c7b0a
--- /dev/null
@@ -0,0 +1,37 @@
+'''
+Created on 02.08.2024
+
+@author: sparky2021
+'''
+from eh_app.models import ConfigData
+
+the_instance = None
+
+class Config:
+    '''
+    Singleton Klasse für Konfiguration
+    '''
+
+    def __init__(self, verein):
+        self.verein = verein
+        
+    def getConfig(self, key, default=None):
+        data = ConfigData.objects.filter(verein=self.verein, key=key)
+        if data:
+            return data[0].value
+        return default
+    
+    def requireConfig(self, key):
+        data = self.getConfig(key)
+        if not data:
+            raise RuntimeError(f"Kein Eintag für: {self.verein}/{key}")
+        return data
+        
+
+def getInstance(verein=None):
+    global the_instance
+    if not the_instance:
+        if not verein:
+            raise RuntimeError("Bei der ersten Instanzierung muss der Verein mitgegeben werden.")
+        the_instance = Config(verein)
+    return the_instance
diff --git a/python/eh_util/eh_app/AWK/routines.py b/python/eh_util/eh_app/AWK/routines.py
new file mode 100644 (file)
index 0000000..76a2c96
--- /dev/null
@@ -0,0 +1,26 @@
+import os
+'''
+def handle_uploaded_file(csv_file):
+    csv_file_name = str(csv_file)
+    data_path = config.getInstance().requireConfig("data_path")
+    path = os.path.join(data_path, csv_file_name)
+    with open(path, 'wb+') as destination:
+        for chunk in csv_file.chunks():
+            destination.write(chunk)
+'''
+def aktualisiere_config(config, data):
+    if data["briefpapier"]:
+        uploaded_file = data["briefpapier"]
+        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():
+                destination.write(chunk)
+        config.set_config("briefpapier", uploaded_file.name)
+    
+    if data["basisbeitrag"]:
+        config.set_config("beitrag_basis", data["basisbeitrag"])
+        
+    if data["zusatzbeitrag"]:
+        config.set_config("beitrag_zusatz", data["zusatzbeitrag"])
+        
\ No newline at end of file
diff --git a/python/eh_util/eh_app/migrations/0001_initial.py b/python/eh_util/eh_app/migrations/0001_initial.py
new file mode 100644 (file)
index 0000000..84ca6ad
--- /dev/null
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.28 on 2024-11-08 19:25
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='ConfigData',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('verein', models.CharField(max_length=100)),
+                ('key', models.CharField(max_length=50)),
+                ('value', models.CharField(max_length=200)),
+            ],
+        ),
+    ]
diff --git a/python/eh_util/eh_app/migrations/__init__.py b/python/eh_util/eh_app/migrations/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/python/eh_util/eh_app/templates/__init__.py b/python/eh_util/eh_app/templates/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/python/eh_util/eh_app/templates/kassenbrief.html b/python/eh_util/eh_app/templates/kassenbrief.html
new file mode 100644 (file)
index 0000000..f15de74
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+       <title>Siedlerverein-Verwaltung by WagnerTech UG</title>
+</head>
+<body>
+<h1>Erstellung Kassenbrief</h1>
+<p>Überprüfen Sie folgende Eingabedaten</p>
+<form action="/{{verein}}/kassenbrief/" method="post">
+{% csrf_token %}
+<table>
+<tr><th>Briefpapier:</th><td>{{briefpapier}}</td></tr>
+{{form}}
+</table>
+<p><input type="submit" value="Erstellen"/>
+</form>
+</body>
+</html>