pydev-s6git
authorMichael Wagner <mail@wagnertech.de>
Fri, 2 Aug 2024 08:14:44 +0000 (10:14 +0200)
committerMichael Wagner <mail@wagnertech.de>
Fri, 2 Aug 2024 08:14:44 +0000 (10:14 +0200)
14 files changed:
debian/eigenheimer-util.changelog [new file with mode: 0644]
debian/eigenheimer-util.conf [new file with mode: 0644]
debian/eigenheimer-util.control [new file with mode: 0644]
debian/eigenheimer-util.cp [new file with mode: 0755]
debian/eigenheimer-util.postinst [new file with mode: 0755]
python/eh_util/ausweis/AWK/config.py [new file with mode: 0644]
python/eh_util/ausweis/AWK/routines.py [new file with mode: 0644]
python/eh_util/ausweis/migrations/0001_initial.py [new file with mode: 0644]
python/eh_util/ausweis/migrations/__init__.py [new file with mode: 0644]
python/eh_util/ausweis/models.py
python/eh_util/ausweis/templates/__init__.py [new file with mode: 0644]
python/eh_util/ausweis/templates/anschreiben.html [new file with mode: 0644]
python/eh_util/ausweis/templates/index.html [new file with mode: 0644]
python/eh_util/ausweis/views.py

diff --git a/debian/eigenheimer-util.changelog b/debian/eigenheimer-util.changelog
new file mode 100644 (file)
index 0000000..b46e673
--- /dev/null
@@ -0,0 +1,4 @@
+svbal (0.1-%BUILD%) unstable; urgency=medium
+  * initial version: Ausweiserstellung
+ -- Michael Wagner <info@wagnertech.de>  Sat, 06 Jun 2020 20:03:04 +0100
+
diff --git a/debian/eigenheimer-util.conf b/debian/eigenheimer-util.conf
new file mode 100644 (file)
index 0000000..4f91cd7
--- /dev/null
@@ -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 (file)
index 0000000..b928661
--- /dev/null
@@ -0,0 +1,12 @@
+Source: svbal
+Section: main
+Priority: optional
+Maintainer: Michael Wagner <michael@wagnertech.de>
+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 (executable)
index 0000000..52024fb
--- /dev/null
@@ -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 (executable)
index 0000000..475ac41
--- /dev/null
@@ -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 (file)
index 0000000..9011222
--- /dev/null
@@ -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 (file)
index 0000000..619048f
--- /dev/null
@@ -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 (file)
index 0000000..20f6315
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
index 92cc381..85a0701 100644 (file)
@@ -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 (file)
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 (file)
index 0000000..42947b0
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>WagnerTech - Siedlerverein</title>
+</head>
+
+<body>
+<h1>Anschreiben für den Ausweis</h1>
+<form action="anschreiben" method="post" enctype="multipart/form-data">
+{% csrf_token %}
+<p>{{ form.text.label_tag }} {{ form.text }}</p>
+
+        <p><input type="submit" value="Anschreiben erstellen"/></p>
+</form>
+</body>
+</html>
diff --git a/python/eh_util/ausweis/templates/index.html b/python/eh_util/ausweis/templates/index.html
new file mode 100644 (file)
index 0000000..93369a6
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+       <title>Siedlerverein-Verwaltung by WagnerTech UG</title>
+</head>
+<body>
+<h1>Erstellung Mitgliederausweise</h1>
+{% if csv_datei_name %}
+       <p>S-Verein-Export: {{csv_datei_name}}</p>
+       <p><a href="upload">Datei ändern</a></p>
+{% else %}
+       <p><a href="upload">Datei hochladen</a></p>
+{% endif %}
+<p><a href="anschreiben">Anschreiben erstellen</a></p>
+<p><a href="alle_ausweise">Alle Ausweise erstellen</a></p>
+<p><a href="einzelausweis">Einzelnen Ausweis erstellen</a></p>
+</body>
+</html>
index ba2b10c..8d5f300 100644 (file)
@@ -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()