--- /dev/null
+'''
+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
--- /dev/null
+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
--- /dev/null
+# 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)),
+ ],
+ ),
+ ]
--- /dev/null
+<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>