From c47732d875fd7264cfbfb1f7d99d11af9d90b62a Mon Sep 17 00:00:00 2001 From: eclipse Date: Thu, 1 May 2025 12:13:03 +0200 Subject: [PATCH] added support for DB table "Verlag" --- the_works/__init__.py | 3 +- the_works/models.py | 2 + the_works/static/the_works.css | 4 + the_works/templates/_nav.html | 5 +- the_works/templates/views/verlag.html | 103 ++++++++++++++++++++++++++ the_works/views/verlag.py | 39 ++++++++++ 6 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 the_works/templates/views/verlag.html create mode 100644 the_works/views/verlag.py diff --git a/the_works/__init__.py b/the_works/__init__.py index b6bdf4d..4bb6ab8 100644 --- a/the_works/__init__.py +++ b/the_works/__init__.py @@ -19,10 +19,11 @@ def create_app(): init_db(app) # register blueprints - from the_works.views import home, text, werk + from the_works.views import home, text, werk, verlag app.register_blueprint(text.bp) app.register_blueprint(home.bp) app.register_blueprint(werk.bp) + app.register_blueprint(verlag.bp) ### DEBUG app.config["SQLALCHEMY_ECHO"] = True diff --git a/the_works/models.py b/the_works/models.py index ac4e416..84f84c1 100644 --- a/the_works/models.py +++ b/the_works/models.py @@ -23,6 +23,7 @@ class Reihe(db.Model): __table__ = db.Model.metadata.tables['Reihe'] text = relationship("Text", back_populates="reihe") werk = relationship("Werk", back_populates="reihe") + verlag = relationship("Verlag", back_populates="reihe") class Textform(db.Model): __table__ = db.Model.metadata.tables['Textform'] @@ -35,6 +36,7 @@ class Sprache(db.Model): class Verlag(db.Model): __table__ = db.Model.metadata.tables['Verlag'] werk = relationship("Werk", back_populates="verlag") + reihe = relationship("Reihe", back_populates="verlag") class Werksform(db.Model): __table__ = db.Model.metadata.tables['Werksform'] diff --git a/the_works/static/the_works.css b/the_works/static/the_works.css index 308702a..1c603f5 100644 --- a/the_works/static/the_works.css +++ b/the_works/static/the_works.css @@ -10,4 +10,8 @@ table.dataTable td.action { #text-table_wrapper .dt-search input[type="search"] { background-image: none; +} + +svg { + height: 1.5em; } \ No newline at end of file diff --git a/the_works/templates/_nav.html b/the_works/templates/_nav.html index 111418e..376b98b 100644 --- a/the_works/templates/_nav.html +++ b/the_works/templates/_nav.html @@ -6,11 +6,12 @@

the_works

Tobias Radloffs Bücher

- - + + diff --git a/the_works/templates/views/verlag.html b/the_works/templates/views/verlag.html new file mode 100644 index 0000000..cb41ffc --- /dev/null +++ b/the_works/templates/views/verlag.html @@ -0,0 +1,103 @@ +{% extends 'base.html' %} + +{% block title %}Verlage{% endblock title %} + +{% block script %} +{% endblock script %} + +{% block heading %}Verlage{% endblock heading %} + +{% block content %} + +{% include "_icons.svg" %} + + + + + + + + + + {% for verlag in verlage %} + + + + + + {% endfor %} + +
VerlagAktionen
{{ verlag["Verlag"] }}
+ + +
+
+
+ +

#

+
+ +
+
+ +
+
+ +
+ + +
+
+
+
+{% endblock content %} \ No newline at end of file diff --git a/the_works/views/verlag.py b/the_works/views/verlag.py new file mode 100644 index 0000000..8c9c1ac --- /dev/null +++ b/the_works/views/verlag.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 Verlag + +bp = Blueprint("verlag", __name__) + +@bp.route("/verlag") +@bp.route("/verlag/all") +def all(): + return render_template("views/verlag.html", verlage=db.session.scalars(select(Verlag))) + +@bp.route("/text/verlag/") +def read(id): + return db.session.get(Verlag, id) + +@bp.route("/verlag/create", methods=["POST"]) +def create(): + db.session.add(Verlag(Verlag = request.form["form_Verlag"])) + db.session.commit() + flash("Eintrag erfolgreich hinzugefügt") + return redirect(url_for("verlag.all")) + +@bp.route("/verlag/update/", methods=["POST"]) +def update(id): + verlag = db.session.get(Verlag, id) + verlag.Verlag = request.form["form_Verlag"] + db.session.commit() + flash("Eintrag erfolgreich geändert") + return redirect(url_for("verlag.all")) + +@bp.route("/verlag/delete/") +def delete(id): + verlag = db.session.get(Verlag, id) + db.session.delete(verlag) + db.session.commit() + flash("Eintrag erfolgreich gelöscht") + return redirect(url_for("verlag.all")) +