-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fifthaccess
committed
May 10, 2022
1 parent
956876b
commit b7544ce
Showing
7 changed files
with
184 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
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.templating import render_template | ||
from flask import Blueprint | ||
import sqlalchemy | ||
import sqlalchemy.orm | ||
from forms.lied import DeleteLiederForm, EditLiedForm, LiedForm | ||
from model.models import Lied, db | ||
|
||
|
||
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") | ||
|
||
@lied_blueprint.route('/lieder/add', methods=["Get", "Post"]) | ||
def Lieder_add(): | ||
session : sqlalchemy.orm.scoping.scoped_session = db.session | ||
|
||
add_lied_form = LiedForm() | ||
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() | ||
|
||
print("data is valid") | ||
#new_manager.ManagerId = add_manager_form.ManagerID.data | ||
|
||
new_Lied.Kuenstleranzahl = add_lied_form.Kuenstleranzahl.data | ||
new_Lied.Liedname = add_lied_form.Liedname.data | ||
new_Lied.Erscheinungsdatum = add_lied_form.Erscheinungsdatum.data | ||
db.session.add(new_Lied) | ||
db.session.commit() | ||
|
||
return redirect("/lieder") | ||
|
||
else: | ||
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) | ||
|
||
@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() | ||
|
||
del_form = DeleteLiederForm() | ||
|
||
if request.method == 'POST': | ||
print("f") | ||
if del_form.validate_on_submit(): | ||
delete_id_string = del_form.CheckedCheckboxes.data | ||
delete_id_list = list(delete_id_string.split(",")) | ||
|
||
print(del_form.CheckedCheckboxes.data) | ||
for i in delete_id_list: | ||
print("deleting now data with id " + i) | ||
itemToDelete = db.session.query(Lied).filter(Lied.LiedId == i) | ||
itemToDelete.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 ) | ||
else: | ||
print("invalide 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 ) | ||
|
||
|
||
@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() | ||
|
||
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 | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from operator import imod | ||
from flask_wtf import FlaskForm | ||
from wtforms.fields.datetime import DateField | ||
from wtforms.fields.simple import BooleanField, StringField, TextAreaField ,HiddenField | ||
from wtforms.fields import DecimalField, FieldList , SelectField , DateField | ||
from wtforms import validators | ||
from model.models import Kuenstler | ||
import sqlalchemy | ||
import sqlalchemy.orm | ||
from model.models import Manager | ||
from model.models import db | ||
|
||
class LiedForm(FlaskForm): | ||
LiedId = HiddenField("LiedId") | ||
Kuenstleranzahl = DecimalField("Kuenstleranzahl") | ||
Liedname = StringField("Liedname") | ||
Erscheinungsdatum = DateField("Erscheinungsdatum") | ||
|
||
|
||
class DeleteLiederForm(FlaskForm): | ||
CheckedCheckboxes = HiddenField("CheckedCheckboxes") | ||
|
||
|
||
class EditLiedForm(FlaskForm): | ||
LiedId = HiddenField("LiedId") | ||
Kuenstleranzahl = DecimalField("Kuenstleranzahl") | ||
Liedname = StringField("Liedname") | ||
Erscheinungsdatum = DateField("Erscheinungsdatum") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters