diff --git a/the_works/__init__.py b/the_works/__init__.py index 1aa58b2..6650682 100644 --- a/the_works/__init__.py +++ b/the_works/__init__.py @@ -14,22 +14,24 @@ def create_app(): app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///" + os.path.abspath(app.root_path + "/..") + "/" + os.getenv("SQLALCHEMY_DATABASE_SQLITE_FILENAME") else: exit("no SQLite database URI given; exiting") - + # initialize database init_db(app) # register blueprints - from the_works.views import home, text, werk, verlag, sprache + from the_works.views import home, text, werk, verlag, sprache, textform, werksform app.register_blueprint(text.bp) app.register_blueprint(home.bp) app.register_blueprint(werk.bp) app.register_blueprint(verlag.bp) app.register_blueprint(sprache.bp) + app.register_blueprint(textform.bp) + app.register_blueprint(werksform.bp) ### DEBUG - app.config["SQLALCHEMY_ECHO"] = True - print(f"Current Environment: " + app.config['ENVIRONMENT']) - # load debug toolbar toolbar = DebugToolbarExtension(app) + app.config["SQLALCHEMY_ECHO"] = True + app.config['SQLALCHEMY_RECORD_QUERIES'] = os.getenv("SQLALCHEMY_RECORD_QUERIES") + print(f"Current Environment: " + app.config['ENVIRONMENT']) return app diff --git a/the_works/templates/_nav.html b/the_works/templates/_nav.html index 43a11a1..7c60f64 100644 --- a/the_works/templates/_nav.html +++ b/the_works/templates/_nav.html @@ -14,5 +14,7 @@
  • Werke
  • Verlage
  • Sprachen
  • +
  • Textformen
  • +
  • Werksformen
  • diff --git a/the_works/templates/views/textform.html b/the_works/templates/views/textform.html new file mode 100644 index 0000000..a77024f --- /dev/null +++ b/the_works/templates/views/textform.html @@ -0,0 +1,103 @@ +{% extends 'base.html' %} + +{% block title %}Textformen{% endblock title %} + +{% block script %} +{% endblock script %} + +{% block heading %}Textformen{% endblock heading %} + +{% block content %} + +{% include "_icons.svg" %} + + + + + + + + + + {% for textform in textformen %} + + + + + + {% endfor %} + +
    TextformenAktionen
    {{ textform["Textform"] }}
    + + +
    +
    +
    + +

    #

    +
    + +
    +
    + +
    +
    + + +
    +
    +
    +{% endblock content %} \ No newline at end of file diff --git a/the_works/templates/views/werksform.html b/the_works/templates/views/werksform.html new file mode 100644 index 0000000..06f715d --- /dev/null +++ b/the_works/templates/views/werksform.html @@ -0,0 +1,103 @@ +{% extends 'base.html' %} + +{% block title %}Werksformen{% endblock title %} + +{% block script %} +{% endblock script %} + +{% block heading %}Werksformen{% endblock heading %} + +{% block content %} + +{% include "_icons.svg" %} + + + + + + + + + + {% for werksform in werksformen %} + + + + + + {% endfor %} + +
    WerksformenAktionen
    {{ werksform["Werksform"] }}
    + + +
    +
    +
    + +

    #

    +
    + +
    +
    + +
    +
    + + +
    +
    +
    +{% endblock content %} \ No newline at end of file diff --git a/the_works/views/textform.py b/the_works/views/textform.py new file mode 100644 index 0000000..4c365d9 --- /dev/null +++ b/the_works/views/textform.py @@ -0,0 +1,39 @@ +from flask import Blueprint, render_template, request, redirect, flash, url_for +from sqlalchemy import select, insert, update, delete +from the_works.database import db +from the_works.models import Textform + +bp = Blueprint("textform", __name__) + +@bp.route("/textform") +@bp.route("/textform/all") +def all(): + return render_template("views/textform.html", textformen=db.session.scalars(select(Textform))) + +@bp.route("/textform/verlag/") +def read(id): + return db.session.get(Textform, id) + +@bp.route("/textform/create", methods=["POST"]) +def create(): + db.session.add(Textform(Textform = request.form["form_Textform"])) + db.session.commit() + flash("Eintrag erfolgreich hinzugefügt") + return redirect(url_for("textform.all"), code=303) + +@bp.route("/textform/update/", methods=["POST"]) +def update(id): + textform = db.session.get(Textform, id) + textform.Textform = request.form["form_Textform"] + db.session.commit() + flash("Eintrag erfolgreich geändert") + return redirect(url_for("textform.all"), code=303) + +@bp.route("/textform/delete/") +def delete(id): + textform = db.session.get(Textform, id) + db.session.delete(textform) + db.session.commit() + flash("Eintrag erfolgreich gelöscht") + return redirect(url_for("textform.all")) + diff --git a/the_works/views/werksform.py b/the_works/views/werksform.py new file mode 100644 index 0000000..f3c8a62 --- /dev/null +++ b/the_works/views/werksform.py @@ -0,0 +1,39 @@ +from flask import Blueprint, render_template, request, redirect, flash, url_for +from sqlalchemy import select, insert, update, delete +from the_works.database import db +from the_works.models import Werksform + +bp = Blueprint("werksform", __name__) + +@bp.route("/werksform") +@bp.route("/werksform/all") +def all(): + return render_template("views/werksform.html", werksformen=db.session.scalars(select(Werksform))) + +@bp.route("/werksform/verlag/") +def read(id): + return db.session.get(Werksform, id) + +@bp.route("/werksform/create", methods=["POST"]) +def create(): + db.session.add(Werksform(Werksform = request.form["form_Werksform"])) + db.session.commit() + flash("Eintrag erfolgreich hinzugefügt") + return redirect(url_for("werksform.all"), code=303) + +@bp.route("/werksform/update/", methods=["POST"]) +def update(id): + werksform = db.session.get(Werksform, id) + werksform.Werksform = request.form["form_Werksform"] + db.session.commit() + flash("Eintrag erfolgreich geändert") + return redirect(url_for("werksform.all"), code=303) + +@bp.route("/werksform/delete/") +def delete(id): + werksform = db.session.get(Werksform, id) + db.session.delete(werksform) + db.session.commit() + flash("Eintrag erfolgreich gelöscht") + return redirect(url_for("werksform.all")) +