From 30208d56cd285dd90ac5c85a5dad0f2ceed29c06 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Sat, 9 Nov 2024 23:04:47 +0100 Subject: [PATCH] pydev-s6 --- python/eh_util/eh_app/AWK/config.py | 37 +++++++++++++++++++ python/eh_util/eh_app/AWK/routines.py | 26 +++++++++++++ .../eh_util/eh_app/migrations/0001_initial.py | 23 ++++++++++++ python/eh_util/eh_app/migrations/__init__.py | 0 python/eh_util/eh_app/templates/__init__.py | 0 .../eh_util/eh_app/templates/kassenbrief.html | 17 +++++++++ 6 files changed, 103 insertions(+) create mode 100644 python/eh_util/eh_app/AWK/config.py create mode 100644 python/eh_util/eh_app/AWK/routines.py create mode 100644 python/eh_util/eh_app/migrations/0001_initial.py create mode 100644 python/eh_util/eh_app/migrations/__init__.py create mode 100644 python/eh_util/eh_app/templates/__init__.py create mode 100644 python/eh_util/eh_app/templates/kassenbrief.html diff --git a/python/eh_util/eh_app/AWK/config.py b/python/eh_util/eh_app/AWK/config.py new file mode 100644 index 0000000..47c7b0a --- /dev/null +++ b/python/eh_util/eh_app/AWK/config.py @@ -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 index 0000000..76a2c96 --- /dev/null +++ b/python/eh_util/eh_app/AWK/routines.py @@ -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 index 0000000..84ca6ad --- /dev/null +++ b/python/eh_util/eh_app/migrations/0001_initial.py @@ -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 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 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 index 0000000..f15de74 --- /dev/null +++ b/python/eh_util/eh_app/templates/kassenbrief.html @@ -0,0 +1,17 @@ + + + Siedlerverein-Verwaltung by WagnerTech UG + + +

Erstellung Kassenbrief

+

Überprüfen Sie folgende Eingabedaten

+
+{% csrf_token %} + + +{{form}} +
Briefpapier:{{briefpapier}}
+

+

+ + -- 2.20.1