From dd9057c24cd3b192bcda1b1730b3cec0fabf6ce7 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Fri, 2 Aug 2024 10:14:44 +0200 Subject: [PATCH] pydev-s6git --- debian/eigenheimer-util.changelog | 4 ++ debian/eigenheimer-util.conf | 2 + debian/eigenheimer-util.control | 12 ++++++ debian/eigenheimer-util.cp | 12 ++++++ debian/eigenheimer-util.postinst | 13 +++++++ python/eh_util/ausweis/AWK/config.py | 37 +++++++++++++++++++ python/eh_util/ausweis/AWK/routines.py | 12 ++++++ .../ausweis/migrations/0001_initial.py | 23 ++++++++++++ python/eh_util/ausweis/migrations/__init__.py | 0 python/eh_util/ausweis/models.py | 12 +++--- python/eh_util/ausweis/templates/__init__.py | 0 .../ausweis/templates/anschreiben.html | 17 +++++++++ python/eh_util/ausweis/templates/index.html | 17 +++++++++ python/eh_util/ausweis/views.py | 11 ++++-- 14 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 debian/eigenheimer-util.changelog create mode 100644 debian/eigenheimer-util.conf create mode 100644 debian/eigenheimer-util.control create mode 100755 debian/eigenheimer-util.cp create mode 100755 debian/eigenheimer-util.postinst create mode 100644 python/eh_util/ausweis/AWK/config.py create mode 100644 python/eh_util/ausweis/AWK/routines.py create mode 100644 python/eh_util/ausweis/migrations/0001_initial.py create mode 100644 python/eh_util/ausweis/migrations/__init__.py create mode 100644 python/eh_util/ausweis/templates/__init__.py create mode 100644 python/eh_util/ausweis/templates/anschreiben.html create mode 100644 python/eh_util/ausweis/templates/index.html diff --git a/debian/eigenheimer-util.changelog b/debian/eigenheimer-util.changelog new file mode 100644 index 0000000..b46e673 --- /dev/null +++ b/debian/eigenheimer-util.changelog @@ -0,0 +1,4 @@ +svbal (0.1-%BUILD%) unstable; urgency=medium + * initial version: Ausweiserstellung + -- Michael Wagner Sat, 06 Jun 2020 20:03:04 +0100 + diff --git a/debian/eigenheimer-util.conf b/debian/eigenheimer-util.conf new file mode 100644 index 0000000..4f91cd7 --- /dev/null +++ b/debian/eigenheimer-util.conf @@ -0,0 +1,2 @@ +compile_type=NONE +target_type=DEB diff --git a/debian/eigenheimer-util.control b/debian/eigenheimer-util.control new file mode 100644 index 0000000..b928661 --- /dev/null +++ b/debian/eigenheimer-util.control @@ -0,0 +1,12 @@ +Source: svbal +Section: main +Priority: optional +Maintainer: Michael Wagner +Build-Depends: git, mbuild + +Package: eigenheimer-util +Architecture: all +Depends: texlive-latex-base, texlive-latex-recommended, texlive-lang-german, python3, apache2, libapache2-mod-wsgi-py3 +Description: Mitgliederverwaltung Eigenheimerverband + . + diff --git a/debian/eigenheimer-util.cp b/debian/eigenheimer-util.cp new file mode 100755 index 0000000..52024fb --- /dev/null +++ b/debian/eigenheimer-util.cp @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +mkdir -p $1/opt +cp -r python/eh_util $1/opt + +# DB löschen +rm $1/opt/eh_util/db.sqlite3 + +mkdir -p $1/etc/apache2/sites-available/ +cp etc/eh_util.conf $1/etc/apache2/sites-available/ + diff --git a/debian/eigenheimer-util.postinst b/debian/eigenheimer-util.postinst new file mode 100755 index 0000000..475ac41 --- /dev/null +++ b/debian/eigenheimer-util.postinst @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +# DB anlegen/migrieren +/opt/eh_util/manage.py migrate + +# activate verleihnix configuration +if ! test -e /etc/apache2/sites-enabled/eh_util.conf +then + a2ensite eh_util + systemctl reload apache2 + echo "eh_util configration enabled" +fi diff --git a/python/eh_util/ausweis/AWK/config.py b/python/eh_util/ausweis/AWK/config.py new file mode 100644 index 0000000..9011222 --- /dev/null +++ b/python/eh_util/ausweis/AWK/config.py @@ -0,0 +1,37 @@ +''' +Created on 02.08.2024 + +@author: sparky2021 +''' +from ausweis.models import ConfigData + +the_instance = None + +class Config: + ''' + Singleton Klasse für Konfiguration + ''' + + def __init__(self, verein): + self.verein = verein + + def getConfig(self, key): + data = ConfigData.objects.filter(verein=self.verein, key=key) + if data: + return data[0].value + return None + + 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/ausweis/AWK/routines.py b/python/eh_util/ausweis/AWK/routines.py new file mode 100644 index 0000000..619048f --- /dev/null +++ b/python/eh_util/ausweis/AWK/routines.py @@ -0,0 +1,12 @@ +from ausweis.AWK import config + +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) + \ No newline at end of file diff --git a/python/eh_util/ausweis/migrations/0001_initial.py b/python/eh_util/ausweis/migrations/0001_initial.py new file mode 100644 index 0000000..20f6315 --- /dev/null +++ b/python/eh_util/ausweis/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.28 on 2024-08-02 07:38 + +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/ausweis/migrations/__init__.py b/python/eh_util/ausweis/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python/eh_util/ausweis/models.py b/python/eh_util/ausweis/models.py index 92cc381..85a0701 100644 --- a/python/eh_util/ausweis/models.py +++ b/python/eh_util/ausweis/models.py @@ -1,12 +1,12 @@ from django.db import models -class ConfigData(models.Model): - verein = models.CharField(max_length=100) - datei = models.CharField(max_length=200) - data_path = models.CharField(max_length=200) - """ Falls hier Änderungen gemacht werden: - ./manage.py makemigrations ausweis - ./manage.py migrate -""" \ No newline at end of file +""" + +class ConfigData(models.Model): + verein = models.CharField(max_length=100) + key = models.CharField(max_length=50) + value = models.CharField(max_length=200) diff --git a/python/eh_util/ausweis/templates/__init__.py b/python/eh_util/ausweis/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python/eh_util/ausweis/templates/anschreiben.html b/python/eh_util/ausweis/templates/anschreiben.html new file mode 100644 index 0000000..42947b0 --- /dev/null +++ b/python/eh_util/ausweis/templates/anschreiben.html @@ -0,0 +1,17 @@ + + + + + WagnerTech - Siedlerverein + + + +

Anschreiben für den Ausweis

+
+{% csrf_token %} +

{{ form.text.label_tag }} {{ form.text }}

+ +

+
+ + diff --git a/python/eh_util/ausweis/templates/index.html b/python/eh_util/ausweis/templates/index.html new file mode 100644 index 0000000..93369a6 --- /dev/null +++ b/python/eh_util/ausweis/templates/index.html @@ -0,0 +1,17 @@ + + + Siedlerverein-Verwaltung by WagnerTech UG + + +

Erstellung Mitgliederausweise

+{% if csv_datei_name %} +

S-Verein-Export: {{csv_datei_name}}

+

Datei ändern

+{% else %} +

Datei hochladen

+{% endif %} +

Anschreiben erstellen

+

Alle Ausweise erstellen

+

Einzelnen Ausweis erstellen

+ + diff --git a/python/eh_util/ausweis/views.py b/python/eh_util/ausweis/views.py index ba2b10c..8d5f300 100644 --- a/python/eh_util/ausweis/views.py +++ b/python/eh_util/ausweis/views.py @@ -1,4 +1,4 @@ -from .AWK import routines +from .AWK import routines, config from .forms import UploadFileForm, DocumentForm, TextInputForm from django.http import HttpResponse, HttpResponseRedirect @@ -9,7 +9,8 @@ from django.template import loader def index(request, verein): # check existence in DB - csv_datei_name = routines.getCsvDateiName(verein) + vconf = config.getInstance(verein) + csv_datei_name = vconf.getConfig("csv_datei_name") if not csv_datei_name: template = loader.get_template('index.html') context = { @@ -20,10 +21,12 @@ def index(request, verein): def upload(request, verein): if request.method == 'POST': + # initialize configuration + config.getInstance(verein) form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): - routines.handle_uploaded_file(verein, request.FILES['file1']) - return HttpResponseRedirect('') + routines.handle_uploaded_file(request.FILES['file1']) + return HttpResponseRedirect(f'/{verein}/ausweis') return HttpResponse("Dateiverarbeitung fehlerhaft") else: form = UploadFileForm() -- 2.20.1