pydev-s6
authorMichael Wagner <michael@wagnertech.de>
Sat, 9 Nov 2024 22:04:23 +0000 (23:04 +0100)
committerMichael Wagner <michael@wagnertech.de>
Sat, 9 Nov 2024 22:04:23 +0000 (23:04 +0100)
python/eh_util/eh_app/AWK/.dummy [new file with mode: 0644]
python/eh_util/eh_app/__init__.py [new file with mode: 0644]
python/eh_util/eh_app/admin.py [new file with mode: 0644]
python/eh_util/eh_app/apps.py [new file with mode: 0644]
python/eh_util/eh_app/forms.py [new file with mode: 0644]
python/eh_util/eh_app/migrations/.dummy [new file with mode: 0644]
python/eh_util/eh_app/models.py [new file with mode: 0644]
python/eh_util/eh_app/templates/.dummy [new file with mode: 0644]
python/eh_util/eh_app/tests.py [new file with mode: 0644]
python/eh_util/eh_app/urls.py [new file with mode: 0644]
python/eh_util/eh_app/views.py [new file with mode: 0644]

diff --git a/python/eh_util/eh_app/AWK/.dummy b/python/eh_util/eh_app/AWK/.dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/python/eh_util/eh_app/__init__.py b/python/eh_util/eh_app/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/python/eh_util/eh_app/admin.py b/python/eh_util/eh_app/admin.py
new file mode 100644 (file)
index 0000000..d654f08
--- /dev/null
@@ -0,0 +1,9 @@
+from django.contrib import admin
+
+# Register your models here.
+
+from django.contrib import admin
+
+from .models import ConfigData
+
+admin.site.register(ConfigData)
diff --git a/python/eh_util/eh_app/apps.py b/python/eh_util/eh_app/apps.py
new file mode 100644 (file)
index 0000000..0d52b41
--- /dev/null
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class EhAppConfig(AppConfig):
+    name = 'eh_app'
diff --git a/python/eh_util/eh_app/forms.py b/python/eh_util/eh_app/forms.py
new file mode 100644 (file)
index 0000000..cc438ab
--- /dev/null
@@ -0,0 +1,28 @@
+from django import forms
+'''
+class UploadFileForm(forms.Form):
+    file1 = forms.FileField(label='S-Verein-Export')
+    
+class DocumentForm(forms.Form):
+    docfile = forms.FileField(
+        label='Select a file',
+        help_text='max. 42 megabytes'
+    )
+
+class TextInputForm(forms.Form):
+    text = forms.CharField(
+        label = "Text für das Anschreiben",
+        empty_value = "Bitte Text eingeben ...",
+        widget=forms.Textarea,
+    )
+'''
+'''
+- Doku zu Forms:
+https://docs.djangoproject.com/en/2.2/topics/forms/
+- Doku zu Fields:
+https://docs.djangoproject.com/en/2.2/ref/forms/fields/
+'''
+class KassenbriefForm(forms.Form):
+    briefpapier   = forms.FileField(label='Briefpapier ändern:', required=False)
+    basisbeitrag  = forms.IntegerField()
+    zusatzbeitrag = forms.IntegerField(label="Beitrag für Zusatzgrundstück")
diff --git a/python/eh_util/eh_app/migrations/.dummy b/python/eh_util/eh_app/migrations/.dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/python/eh_util/eh_app/models.py b/python/eh_util/eh_app/models.py
new file mode 100644 (file)
index 0000000..3682c76
--- /dev/null
@@ -0,0 +1,12 @@
+from django.db import models
+
+"""
+Falls hier Änderungen gemacht werden:
+- ./manage.py makemigrations eh_app
+- ./manage.py migrate
+"""
+
+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/eh_app/templates/.dummy b/python/eh_util/eh_app/templates/.dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/python/eh_util/eh_app/tests.py b/python/eh_util/eh_app/tests.py
new file mode 100644 (file)
index 0000000..7ce503c
--- /dev/null
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/python/eh_util/eh_app/urls.py b/python/eh_util/eh_app/urls.py
new file mode 100644 (file)
index 0000000..aeb4913
--- /dev/null
@@ -0,0 +1,9 @@
+from django.urls import path
+
+from . import views
+
+urlpatterns = [
+    path('', views.index),
+    path('kassenbrief/', views.kassenbrief),
+    path('kassenbrief/exec', views.kassenbrief_exec),
+]
diff --git a/python/eh_util/eh_app/views.py b/python/eh_util/eh_app/views.py
new file mode 100644 (file)
index 0000000..6fbd98a
--- /dev/null
@@ -0,0 +1,58 @@
+from django.http import HttpResponse
+from django.shortcuts import render
+from django.template import loader
+
+from .AWK import config, routines
+#import .forms 
+from .forms import KassenbriefForm
+
+# Create your views here.
+
+def index(request, verein):
+    template = loader.get_template("vbasis.html")
+    return HttpResponse(template.render({"verein" : verein}, request))
+
+def kassenbrief(request, verein):
+    # Hole Daten aus der Config
+    vconf = config.getInstance(verein)
+    briefpapier    = vconf.getConfig("briefpapier")
+    beitrag_basis  = vconf.getConfig("beitrag_basis", 0)
+    beitrag_zusatz = vconf.getConfig("beitrag_zusatz", 0)
+    briefpapier_label = briefpapier
+    if not briefpapier:
+        briefpapier_label = "Kein Briefpapier ausgewäht"
+    
+    # if this is a POST request we need to process the form data
+    if request.method == 'POST':
+        # create a form instance and populate it with data from the request:
+        form = KassenbriefForm(request.POST, request.FILES)
+        # check whether it's valid:
+        if form.is_valid():
+            # bei Änderungen Konfiguration aktualisieren
+            routines.aktualisiere_config(vconf, form.cleaned_data)
+            # redirect to a new URL:
+            return HttpResponseRedirect('/thanks/')
+
+    # if a GET (or any other method) we'll create a blank form
+    else:
+        form = KassenbriefForm(initial={'basisbeitrag': beitrag_basis, 'zusatzbeitrag': beitrag_zusatz})
+
+    return render(request, 'kassenbrief.html', {'form': form, 'verein': verein, 'briefpapier': briefpapier_label})
+    
+    '''
+    template = loader.get_template("kassenbrief.html")
+    return HttpResponse(template.render({
+        "verein"         : verein,
+        "briefpapier"    : briefpapier,
+        "beitrag_basis"  : beitrag_basis,
+        "beitrag_zusatz" : beitrag_zusatz
+        }, request))
+
+    '''
+
+def kassenbrief_exec(request, verein):
+    # Hole Formulardaten
+    print (request.POST)
+    print (request.FILES)
+    return HttpResponse("xxx")
+    
\ No newline at end of file