added template and routes for DB table Veroeffentlichung
This commit is contained in:
parent
3e31dbf4e0
commit
02f9d7e614
@ -19,7 +19,7 @@ def create_app():
|
|||||||
init_db(app)
|
init_db(app)
|
||||||
|
|
||||||
# register blueprints
|
# register blueprints
|
||||||
from the_works.views import home, text, werk, verlag, sprache, textform, werksform, genre, pseudonym, reihe, herausgeber
|
from the_works.views import home, text, werk, verlag, sprache, textform, werksform, genre, pseudonym, reihe, herausgeber, veroeffentlichung
|
||||||
app.register_blueprint(home.bp)
|
app.register_blueprint(home.bp)
|
||||||
app.register_blueprint(text.bp)
|
app.register_blueprint(text.bp)
|
||||||
app.register_blueprint(werk.bp)
|
app.register_blueprint(werk.bp)
|
||||||
@ -31,6 +31,7 @@ def create_app():
|
|||||||
app.register_blueprint(pseudonym.bp)
|
app.register_blueprint(pseudonym.bp)
|
||||||
app.register_blueprint(reihe.bp)
|
app.register_blueprint(reihe.bp)
|
||||||
app.register_blueprint(herausgeber.bp)
|
app.register_blueprint(herausgeber.bp)
|
||||||
|
app.register_blueprint(veroeffentlichung.bp)
|
||||||
|
|
||||||
### DEBUG
|
### DEBUG
|
||||||
toolbar = DebugToolbarExtension(app)
|
toolbar = DebugToolbarExtension(app)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
{% set menu = (
|
{% set menu = (
|
||||||
("Texte", url_for("text.all")),
|
("Texte", url_for("text.all")),
|
||||||
("Werke", url_for("werk.all")),
|
("Werke", url_for("werk.all")),
|
||||||
|
("Veröffentlichungen", url_for("veroeffentlichung.all")),
|
||||||
("Basisdaten", (
|
("Basisdaten", (
|
||||||
("Genres", url_for("genre.all")),
|
("Genres", url_for("genre.all")),
|
||||||
("Herausgeber:innen", url_for("herausgeber.all")),
|
("Herausgeber:innen", url_for("herausgeber.all")),
|
||||||
|
|||||||
102
the_works/templates/views/veroeffentlichung.html
Normal file
102
the_works/templates/views/veroeffentlichung.html
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Veröffentlichungen{% endblock title %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='datatables.css') }}">
|
||||||
|
{% endblock head %}
|
||||||
|
|
||||||
|
{% block heading %}Veröffentlichungen{% endblock heading %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% include "_icons.svg" %}
|
||||||
|
|
||||||
|
<table id="veroeffentlichung-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Text</th>
|
||||||
|
<th>Werk</th>
|
||||||
|
<th>Alt. Titel</th>
|
||||||
|
<th>Alt. Untertitel</th>
|
||||||
|
<th>Pseudonym</th>
|
||||||
|
<th colspan="2">Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for veroeffentlichung in veroeffentlichungen %}
|
||||||
|
<tr id="veroeffentlichung-{{ veroeffentlichung['id'] }}">
|
||||||
|
<td title="Text">{{ veroeffentlichung["Text"] }}</td>
|
||||||
|
<td title="Werk">{{ veroeffentlichung["Werk"] }}</td>
|
||||||
|
<td title="Alt. Titel">{{ veroeffentlichung["AltTitel"] }}</td>
|
||||||
|
<td title="Alt. Untertitel">{{ veroeffentlichung["AltUntertitel"] }}</td>
|
||||||
|
<td title="Pseudonym">{{ veroeffentlichung["Pseudonym"] }}</td>
|
||||||
|
<td class="action action-update" data-id="{{ veroeffentlichung['id'] }}" data-text="{{ veroeffentlichung['t_id'] }}" data-werk="{{ veroeffentlichung['w_id'] }}" data-alttitel="{{ veroeffentlichung['AltTitel'] }}" data-altuntertitel="{{ veroeffentlichung['AltUntertitel_id'] }}" data-pseudonym="{{ veroeffentlichung['p_id'] }}"><a href="#" title="Veröffentlichung bearbeiten"><svg viewbox="0 0 24 24"><use href="#update" /></svg></a></td>
|
||||||
|
<td id="delete-{{ veroeffentlichung['id'] }}" class="action"><a onclick="return confirm('Eintrag wirklich löschen?');" href="{{ url_for('veroeffentlichung.delete', id=veroeffentlichung['id']) }}" title="Veröffentlichung löschen"><svg viewbox="0 0 24 24"><use href="#delete" /></svg></a></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<dialog aria-labelledby="dialog-heading" id="veroeffentlichung-modal">
|
||||||
|
<article>
|
||||||
|
<form id="veroeffentlichung_detail_form" method="post" >
|
||||||
|
<header>
|
||||||
|
<button aria-label="close" rel="prev" onclick="veroeffentlichung-modal.close()"></button>
|
||||||
|
<h1 id="dialog-heading">#</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<article>
|
||||||
|
<label>
|
||||||
|
<span class="required">Text</span>
|
||||||
|
<select id="form_Text" name="form_Text" aria-label="Text" placeholder="Text" required autofocus>
|
||||||
|
<option selected value="">kein Text</option>
|
||||||
|
{% for t in texte %}<option value="{{ t.ID }}">{{ t.Titel }}</option>{% endfor %}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span class="required">Werk</span>
|
||||||
|
<select id="form_Werk" name="form_Werk" aria-label="Werk" placeholder="Werk" required>
|
||||||
|
<option selected value="">kein Werk</option>
|
||||||
|
{% for w in werke %}<option value="{{ w.ID }}">{{ w.Titel }}</option>{% endfor %}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Alternativer Titel
|
||||||
|
<input id="form_AltTitel" name="form_AltTitel" aria-Label="Alternativer Titel" placeholder="Alternativen Titel eingeben" />
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Alternativer Untertitel
|
||||||
|
<input id="form_AltUntertitel" name="form_AltUntertitel" aria-Label="Alternativer Untertitel" placeholder="Alternativen Untertitel eingeben" />
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span class="required">Pseudonym</span>
|
||||||
|
<select id="form_Pseudonym" name="form_Pseudonym" aria-label="Pseudonym" placeholder="Pseudonym" required>
|
||||||
|
<option selected value="">Pseudonym auswählen</option>
|
||||||
|
{% for p in pseudonyme %}<option value="{{ p.ID }}">{{ p.Pseudonym }}</option>{% endfor %}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</article>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<footer class="grid">
|
||||||
|
<button id="form_submit" type="submit" formmethod="post" formaction="{{ url_for('veroeffentlichung.create') }}">OK</button>
|
||||||
|
<button class="secondary" aria-label="close" formmethod="dialog" formnovalidate>Abbrechen</button>
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
<script src="{{ url_for('static', filename='datatables.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='the_works.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
initDataTable("veroeffentlichung-table");
|
||||||
|
initCreateButton("veroeffentlichung-table", "Veröffentlichung hinzufügen …");
|
||||||
|
initModal("veroeffentlichung-modal", ["form_Text", "form_Werk", "form_AltTitel", "form_AltUntertitel", "form_Pseudonym"], ["Neue Veröffentlichung", "Veröffentlichung bearbeiten"], ["{{ url_for('veroeffentlichung.create') }}", "{{ url_for('veroeffentlichung.update', id=-1) }}"]);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock script %}
|
||||||
59
the_works/views/veroeffentlichung.py
Normal file
59
the_works/views/veroeffentlichung.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
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 Veroeffentlichung, Text, Werk, Werksform, Pseudonym
|
||||||
|
|
||||||
|
bp = Blueprint("veroeffentlichung", __name__)
|
||||||
|
|
||||||
|
@bp.route("/veroeffentlichung")
|
||||||
|
@bp.route("/veroeffentlichung/all")
|
||||||
|
def all():
|
||||||
|
rows = db.session.execute(select(Veroeffentlichung, Text, Werk, Werksform, Pseudonym).join(Veroeffentlichung.text, isouter=True).join(Veroeffentlichung.werk, isouter=True).join(Veroeffentlichung.pseudonym, isouter=True).join(Werk.werksform))
|
||||||
|
veroeffentlichungen = []
|
||||||
|
for row in rows:
|
||||||
|
veroeffentlichungen.append({
|
||||||
|
"id": row.Veroeffentlichung.ID,
|
||||||
|
"Text": row.Text.Titel,
|
||||||
|
"t_id": row.Veroeffentlichung.Text,
|
||||||
|
"Werk": row.Werk.Titel + " [" + row.Werksform.Werksform + "]",
|
||||||
|
"w_id": row.Veroeffentlichung.Werk,
|
||||||
|
"AltTitel": row.Veroeffentlichung.AltTitel or "",
|
||||||
|
"AltUntertitel": row.Veroeffentlichung.AltUntertitel or "",
|
||||||
|
"Pseudonym": row.Pseudonym.Pseudonym,
|
||||||
|
"p_id": row.Veroeffentlichung.Pseudonym,
|
||||||
|
})
|
||||||
|
return render_template("views/veroeffentlichung.html", veroeffentlichungen=veroeffentlichungen, texte=db.session.scalars(select(Text)), werke=db.session.scalars(select(Werk)), pseudonyme=db.session.scalars(select(Pseudonym)))
|
||||||
|
|
||||||
|
@bp.route("/veroeffentlichung/create", methods=["POST"])
|
||||||
|
def create():
|
||||||
|
db.session.add(Veroeffentlichung(
|
||||||
|
Text = request.form["form_Text"],
|
||||||
|
Werk = request.form["form_Werk"],
|
||||||
|
AltTitel = request.form["form_AltTitel"],
|
||||||
|
AltUntertitel = request.form["form_AltUntertitel"],
|
||||||
|
Pseudonym = request.form["form_Pseudonym"],
|
||||||
|
))
|
||||||
|
db.session.commit()
|
||||||
|
flash("Eintrag erfolgreich hinzugefügt")
|
||||||
|
return redirect(url_for("veroeffentlichung.all"), code=303)
|
||||||
|
|
||||||
|
@bp.route("/veroeffentlichung/update/<int:id>", methods=["POST"])
|
||||||
|
def update(id):
|
||||||
|
veroeffentlichung = db.session.get(Veroeffentlichung, id)
|
||||||
|
veroeffentlichung.Text = request.form["form_Text"]
|
||||||
|
veroeffentlichung.Werk = request.form["form_Werk"]
|
||||||
|
veroeffentlichung.AltTitel = request.form["form_AltTitel"]
|
||||||
|
veroeffentlichung.AltUntertitel = request.form["form_AltUntertitel"]
|
||||||
|
veroeffentlichung.Pseudonym = request.form["form_Pseudonym"]
|
||||||
|
db.session.commit()
|
||||||
|
flash("Eintrag erfolgreich geändert")
|
||||||
|
return redirect(url_for("veroeffentlichung.all"), code=303)
|
||||||
|
|
||||||
|
@bp.route("/veroeffentlichung/delete/<int:id>")
|
||||||
|
def delete(id):
|
||||||
|
veroeffentlichung = db.session.get(Veroeffentlichung, id)
|
||||||
|
db.session.delete(veroeffentlichung)
|
||||||
|
db.session.commit()
|
||||||
|
flash("Eintrag erfolgreich gelöscht")
|
||||||
|
return redirect(url_for("veroeffentlichung.all"))
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user