Skip to content

Commit

Permalink
fixing code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
fifthaccess committed May 17, 2022
1 parent e329628 commit 1e7f617
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 163 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.linting.pylamaEnabled": true,
"python.linting.enabled": true
}
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
app.register_blueprint(manager_blueprint)
app.register_blueprint(kuenstler_blueprint)
app.register_blueprint(lied_blueprint)
if __name__ == "__main__":
app.run(debug=True)
if __name__ == "__main__":
app.run(debug=True)
10 changes: 4 additions & 6 deletions controllers/index.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from operator import index
from flask import Flask
from flask.templating import render_template
from flask import Blueprint
import sqlalchemy
from model.models import db,Kuenstler

index_blueprint = Blueprint('index_blueprint',__name__)

index_blueprint = Blueprint('index_blueprint', __name__)


@index_blueprint.route("/")
def index():

return render_template("index.html", headline="Übersicht")#, form = addItemFormObject, items = items)
# , form = addItemFormObject, items = items)
return render_template("index.html", headline="Übersicht")
111 changes: 68 additions & 43 deletions controllers/kuenstler.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from ast import Del
from operator import index
from pyexpat import model
import string
from click import edit
from flask import Flask, redirect, request, flash
from flask import redirect, request
from flask.templating import render_template
from flask import Blueprint
import sqlalchemy
Expand All @@ -12,57 +7,69 @@
from model.models import Kuenstler, db


kuenstler_blueprint = Blueprint('kuenstler_blueprint',__name__)
kuenstler_blueprint = Blueprint('kuenstler_blueprint', __name__)


@kuenstler_blueprint.route("/kuenstler")
def kuenstler_view():
session : sqlalchemy.orm.scoping.scoped_session = db.session

kuenstler = session.query(Kuenstler).order_by(Kuenstler.KuenstlerId).all()

return render_template("kuenstler/viewKuenstler.html", kuenstlers = kuenstler, headline = "Künstler") # kuenstlers wird nur beutzt wegen dem identischen pural wie singular von kuenstler
session: sqlalchemy.orm.scoping.scoped_session = db.session

kuenstler = session.query(Kuenstler).order_by(Kuenstler.KuenstlerId).all()

# kuenstlers wird nur beutzt wegen dem identischen pural wie singular von kuenstler
return render_template(
"kuenstler/viewKuenstler.html",
kuenstlers=kuenstler,
headline="Künstler")


@kuenstler_blueprint.route('/kuenstler/add', methods=["Get", "Post"])
def kuenstler_add():
session : sqlalchemy.orm.scoping.scoped_session = db.session
session: sqlalchemy.orm.scoping.scoped_session = db.session

add_kuenstler_form = KuenstlerForm()
kuenstler = session.query(Kuenstler).order_by(Kuenstler.KuenstlerId).all()
kuenstler = session.query(Kuenstler).order_by(Kuenstler.KuenstlerId).all()

if request.method == 'POST':
print("f")
if add_kuenstler_form.validate_on_submit():
new_kuenstler = Kuenstler()
new_kuenstler = Kuenstler()

print("data is valid")
#new_manager.ManagerId = add_manager_form.ManagerID.data
# new_manager.ManagerId = add_manager_form.ManagerID.data

new_kuenstler.Vorname = add_kuenstler_form.Vorname.data
new_kuenstler.Nachname = add_kuenstler_form.Nachname.data
new_kuenstler.ManagerId = add_kuenstler_form.ManagerID.data
new_kuenstler.Herkunftsland = add_kuenstler_form.Herkunftsland.data
new_kuenstler.Herkunftsland = add_kuenstler_form.Herkunftsland.data
new_kuenstler.Gehalt = add_kuenstler_form.Gehalt.data
db.session.add(new_kuenstler)
db.session.commit()

return redirect("/kuenstler")

else:
return render_template("kuenstler/addkuenstler.html", headline = "Add Künstler", form = add_kuenstler_form, kuenstlers = kuenstler)

return render_template(
"kuenstler/addkuenstler.html",
headline="Add Künstler",
form=add_kuenstler_form,
kuenstlers=kuenstler)

else:
return render_template("kuenstler/addkuenstler.html", headline = "Add Künstler", form = add_kuenstler_form, kuenstlers = kuenstler)
return render_template(
"kuenstler/addkuenstler.html",
headline="Add Künstler",
form=add_kuenstler_form,
kuenstlers=kuenstler)


@kuenstler_blueprint.route('/kuenstler/delete', methods=["Get", "Post"])
def manager_delete():
session : sqlalchemy.orm.scoping.scoped_session = db.session
kuenstler = session.query(Kuenstler).order_by(Kuenstler.KuenstlerId).all()
session: sqlalchemy.orm.scoping.scoped_session = db.session
kuenstler = session.query(Kuenstler).order_by(Kuenstler.KuenstlerId).all()

del_form = DeleteKuenstlerForm()

if request.method == 'POST':
print("f")
if del_form.validate_on_submit():
Expand All @@ -72,47 +79,65 @@ def manager_delete():
print(del_form.CheckedCheckboxes.data)
for i in delete_id_list:
print("deleting now data with id " + i)
itemToDelete = db.session.query(Kuenstler).filter(Kuenstler.KuenstlerId == i)
itemToDelete = db.session.query(
Kuenstler).filter(Kuenstler.KuenstlerId == i)
itemToDelete.delete()
db.session.commit()
print("deleted data with id " + i)

kuenstler = session.query(Kuenstler).order_by(Kuenstler.KuenstlerId).all()
return render_template("kuenstler/viewkuenstler.html", kuenstlers = kuenstler, headline = "Künstler", form = del_form )
kuenstler = session.query(Kuenstler).order_by(
Kuenstler.KuenstlerId).all()
return render_template(
"kuenstler/viewkuenstler.html",
kuenstlers=kuenstler,
headline="Künstler",
form=del_form)
else:
print("invalide Form")
return render_template("kuenstler/deletekuenstler.html", kuenstlers = kuenstler, headline = "Delete Künstler", form = del_form )

return render_template(
"kuenstler/deletekuenstler.html",
kuenstlers=kuenstler,
headline="Delete Künstler",
form=del_form)

else:
return render_template("kuenstler/deletekuenstler.html", kuenstlers = kuenstler, headline = "Delete Künstler", form = del_form )
return render_template(
"kuenstler/deletekuenstler.html",
kuenstlers=kuenstler,
headline="Delete Künstler",
form=del_form)


@kuenstler_blueprint.route('/kuenstler/edit', methods=["Get", "Post"])
def kuenstler_edit():
edit_kuenstler_id = request.args["itemid"]
edit_kuenstler_form = editKuenstlerForm()

item_to_edit = db.session.query(Kuenstler).filter(Kuenstler.KuenstlerId == edit_kuenstler_id).first()
item_to_edit = db.session.query(Kuenstler).filter(
Kuenstler.KuenstlerId == edit_kuenstler_id).first()

if request.method == 'POST':
print("Post")
if edit_kuenstler_form.validate_on_submit():
print("is validate")


item_to_edit.kuenstlerId = edit_kuenstler_form.KuenstlerId.data
item_to_edit.ManagerId = edit_kuenstler_form.ManagerID.data
item_to_edit.Vorname = edit_kuenstler_form.Vorname.data
item_to_edit.Nachname = edit_kuenstler_form.Nachname.data
item_to_edit.Herkunftsland = edit_kuenstler_form.Herkunftsland.data
item_to_edit.Gehalt = edit_kuenstler_form.Gehalt.data

item_to_edit.kuenstlerId = edit_kuenstler_form.KuenstlerId.data
item_to_edit.ManagerId = edit_kuenstler_form.ManagerID.data
item_to_edit.Vorname = edit_kuenstler_form.Vorname.data
item_to_edit.Nachname = edit_kuenstler_form.Nachname.data
item_to_edit.Herkunftsland = edit_kuenstler_form.Herkunftsland.data
item_to_edit.Gehalt = edit_kuenstler_form.Gehalt.data
db.session.commit()
return redirect("/kuenstler")
else:

edit_kuenstler_form.KuenstlerId.data = item_to_edit.KuenstlerId
edit_kuenstler_form.ManagerID.data = item_to_edit.ManagerId
edit_kuenstler_form.Vorname.data = item_to_edit.Vorname
edit_kuenstler_form.Nachname.data = item_to_edit.Nachname
edit_kuenstler_form.Herkunftsland.data = item_to_edit.Herkunftsland
edit_kuenstler_form.Gehalt.data = item_to_edit.Gehalt
return render_template("kuenstler/editkuenstler.html", headline = "Edit Künstler", form = edit_kuenstler_form)
edit_kuenstler_form.Herkunftsland.data = item_to_edit.Herkunftsland
edit_kuenstler_form.Gehalt.data = item_to_edit.Gehalt
return render_template(
"kuenstler/editkuenstler.html",
headline="Edit Künstler",
form=edit_kuenstler_form)
92 changes: 56 additions & 36 deletions controllers/lied.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from ast import Del
from operator import index
from pyexpat import model
import string
from click import edit
from flask import Flask, redirect, request, flash
from flask import redirect, request
from flask.templating import render_template
from flask import Blueprint
import sqlalchemy
Expand All @@ -12,31 +7,32 @@
from model.models import Lied, db


lied_blueprint = Blueprint('lied_blueprint',__name__)
lied_blueprint = Blueprint('lied_blueprint', __name__)


@lied_blueprint.route("/lieder")
def Lieder_view():
session : sqlalchemy.orm.scoping.scoped_session = db.session

lied = session.query(Lied).order_by(Lied.LiedId).all()

return render_template("lieder/viewlieder.html", lieder = lied, headline = "Lieder")
session: sqlalchemy.orm.scoping.scoped_session = db.session

lied = session.query(Lied).order_by(Lied.LiedId).all()

return render_template("lieder/viewlieder.html", lieder=lied, headline="Lieder")


@lied_blueprint.route('/lieder/add', methods=["Get", "Post"])
def Lieder_add():
session : sqlalchemy.orm.scoping.scoped_session = db.session
session: sqlalchemy.orm.scoping.scoped_session = db.session

add_lied_form = LiedForm()
lied = session.query(Lied).order_by(Lied.LiedId).all()
lied = session.query(Lied).order_by(Lied.LiedId).all()

if request.method == 'POST':
print("f")
if add_lied_form.validate_on_submit():
new_Lied = Lied()
new_Lied = Lied()

print("data is valid")
#new_manager.ManagerId = add_manager_form.ManagerID.data
# new_manager.ManagerId = add_manager_form.ManagerID.data

new_Lied.Kuenstleranzahl = add_lied_form.Kuenstleranzahl.data
new_Lied.Liedname = add_lied_form.Liedname.data
Expand All @@ -47,19 +43,28 @@ def Lieder_add():
return redirect("/lieder")

else:
return render_template("lieder/addlieder.html", headline = "Add Lieder", form = add_lied_form, lieder = lied)

return render_template(
"lieder/addlieder.html",
headline="Add Lieder",
form=add_lied_form,
lieder=lied)

else:
return render_template("lieder/addlieder.html", headline = "Add Lieder", form = add_lied_form, lieder = lied)
return render_template(
"lieder/addlieder.html",
headline="Add Lieder",
form=add_lied_form,
lieder=lied)


@lied_blueprint.route('/lieder/delete', methods=["Get", "Post"])
def lied_delete():

session : sqlalchemy.orm.scoping.scoped_session = db.session
lied = session.query(Lied).order_by(Lied.LiedId).all()
session: sqlalchemy.orm.scoping.scoped_session = db.session
lied = session.query(Lied).order_by(Lied.LiedId).all()

del_form = DeleteLiederForm()

if request.method == 'POST':
print("f")
if del_form.validate_on_submit():
Expand All @@ -74,39 +79,54 @@ def lied_delete():
db.session.commit()
print("deleted data with id " + i)

lied = session.query(Lied).order_by(Lied.LiedId).all()
return render_template("lieder/viewlieder.html", lieder = lied, headline = "Lieder", form = del_form )
lied = session.query(Lied).order_by(Lied.LiedId).all()
return render_template(
"lieder/viewlieder.html",
lieder=lied,
headline="Lieder",
form=del_form)
else:
print("invalide Form")
return render_template("lieder/deletelieder.html", lieder = lied, headline = "Delete Lieder", form = del_form )

return render_template(
"lieder/deletelieder.html",
lieder=lied,
headline="Delete Lieder",
form=del_form)

else:
return render_template("lieder/deletelieder.html", lieder = lied, headline = "Delete Lieder", form = del_form )
return render_template(
"lieder/deletelieder.html",
lieder=lied,
headline="Delete Lieder",
form=del_form)


@lied_blueprint.route('/lieder/edit', methods=["Get", "Post"])
def lied_edit():
edit_lied_id = request.args["itemid"]
edit_lied_form = EditLiedForm()

item_to_edit = db.session.query(Lied).filter(Lied.LiedId == edit_lied_id).first()
item_to_edit = db.session.query(Lied).filter(
Lied.LiedId == edit_lied_id).first()

if request.method == 'POST':
print("Post")
if edit_lied_form.validate_on_submit():
print("is validate")


item_to_edit.LiedId = edit_lied_form.LiedId.data
item_to_edit.Kuenstleranzahl = edit_lied_form.Kuenstleranzahl.data
item_to_edit.Liedname = edit_lied_form.Liedname.data
item_to_edit.Erscheinungsdatum = edit_lied_form.Erscheinungsdatum.data
item_to_edit.LiedId = edit_lied_form.LiedId.data
item_to_edit.Kuenstleranzahl = edit_lied_form.Kuenstleranzahl.data
item_to_edit.Liedname = edit_lied_form.Liedname.data
item_to_edit.Erscheinungsdatum = edit_lied_form.Erscheinungsdatum.data
db.session.commit()
return redirect("/lieder")
else:

edit_lied_form.LiedId.data = item_to_edit.LiedId
edit_lied_form.Kuenstleranzahl.data = item_to_edit.Kuenstleranzahl
edit_lied_form.Liedname.data = item_to_edit.Liedname
edit_lied_form.Erscheinungsdatum.data = item_to_edit.Erscheinungsdatum
return render_template("lieder/editlieder.html", headline = "Edit Lieder", form = edit_lied_form)
return render_template(
"lieder/editlieder.html",
headline="Edit Lieder",
form=edit_lied_form)
Loading

0 comments on commit 1e7f617

Please sign in to comment.