diff --git a/controllers/manager.py b/controllers/manager.py index e6df3b6..09657bf 100644 --- a/controllers/manager.py +++ b/controllers/manager.py @@ -1,3 +1,4 @@ +from ast import Del from operator import index from pyexpat import model from flask import Flask, redirect, request, flash @@ -6,8 +7,8 @@ import sqlalchemy import sqlalchemy.orm from model.models import db -from forms.Manager import ManagerForm -from model.models import Manager +from forms.Manager import ManagerForm , DeleteManagerFrom +from model.models import Manager manager_blueprint = Blueprint('manager_blueprint',__name__) @@ -27,7 +28,7 @@ def manager_add(): add_manager_form = ManagerForm() managers = session.query(Manager).order_by(Manager.ManagerId).all() if request.method == 'POST': - + print("f") if add_manager_form.validate_on_submit(): new_manager = Manager() @@ -45,9 +46,22 @@ def manager_add(): else: return render_template("manager/addmanager.html", headline = "Add Managers", form = add_manager_form, managers = managers) + else: return render_template("manager/addmanager.html", headline = "Add Managers", form = add_manager_form, managers = managers) @manager_blueprint.route('/managers/delete', methods=["Get", "Post"]) -def manager_delete (): +def manager_delete(): session : sqlalchemy.orm.scoping.scoped_session = db.session + managers = session.query(Manager).order_by(Manager.ManagerId).all() + del_form = DeleteManagerFrom() + if request.method == 'POST': + print("f") + if del_form.validate_on_submit(): + print(del_form.CheckedCheckboxes.data) + else: + print("invalide Form") + return render_template("manager/deleteManager.html", managers = managers, headline = "Delete Managers", form = del_form ) + + else: + return render_template("manager/deleteManager.html", managers = managers, headline = "Delete Managers", form = del_form ) \ No newline at end of file diff --git a/forms/Manager.py b/forms/Manager.py index 591333f..55fa61d 100644 --- a/forms/Manager.py +++ b/forms/Manager.py @@ -1,8 +1,8 @@ from operator import imod from flask_wtf import FlaskForm -from wtforms.fields.datetime import DateField +from wtforms.fields.datetime import DateField from wtforms.fields.simple import BooleanField, StringField, TextAreaField ,HiddenField -from wtforms.fields import DecimalField +from wtforms.fields import DecimalField, FieldList from wtforms import validators from model.models import Kuenstler @@ -11,4 +11,7 @@ class ManagerForm(FlaskForm): Vorname = StringField("Vorname") Nachname = StringField("Nachname") Firma = StringField("Firma") - Kuenstler_anzahl = DecimalField("Kuenstler_anzahl") \ No newline at end of file + Kuenstler_anzahl = DecimalField("Kuenstler_anzahl") + +class DeleteManagerFrom(FlaskForm): + CheckedCheckboxes = HiddenField("Checked") diff --git a/templates/manager/deleteManager.html b/templates/manager/deleteManager.html index 85c6791..d5841fe 100644 --- a/templates/manager/deleteManager.html +++ b/templates/manager/deleteManager.html @@ -2,6 +2,41 @@ {%block body%} + + +
  • View Managers
  • Add Managers
  • - + +
    + + + + + + + + + + + + - - {{form.csrf_token}} - - - - -
    - - {{form.Vorname(class_="form-control")}} -
    + {% for manager in managers %} + + + + + + + -
    - - {{form.Nachname(class_="form-control")}} -
    + + + {% endfor %} -
    - - {{form.Firma(class_="form-control")}} -
    -
    - - {{form.Kuenstler_anzahl(class_="form-control")}} -
    + +
    IDVornameNachnameFirmaKuenstler_anzahlDelete❌
    {{manager.ManagerId}}{{manager.Vorname}}{{manager.Nachname}}{{manager.Firma}}{{manager.Kuenstler_anzahl}}
    + + - +
    {%endblock%} \ No newline at end of file