diff --git a/schilder2000/instance.py b/schilder2000/instance.py index be9d33264470303c2246cb37a693a413c01fa53a..5f77d66bd164da2fd5e3ecf6a8f48d6a10221020 100644 --- a/schilder2000/instance.py +++ b/schilder2000/instance.py @@ -19,7 +19,7 @@ bp = Blueprint( def schild_html(ident): schild = db.get_or_404(Schild, ident) # raise Exception - return bp.render_template("schild.html.j2", schild=schild) + return bp.render_template(schild.template, schild=schild) @bp.route('/schild/<ident>.pdf') diff --git a/schilder2000/models.py b/schilder2000/models.py index d095df0bec5935f878212339738a18c5ff715dcb..0935671994e273bc816e4a33d8f1cb0ba7883f5d 100644 --- a/schilder2000/models.py +++ b/schilder2000/models.py @@ -1,5 +1,3 @@ -import json -from pathlib import Path from uuid import UUID from uuid_extensions import uuid7 @@ -11,20 +9,8 @@ from . import db class Schild(db.Model): - ident: Mapped[UUID] = mapped_column(primary_key=True, - default=uuid7) + ident: Mapped[UUID] = mapped_column(primary_key=True, default=uuid7) title: Mapped[str] = mapped_column(String(31)) text: Mapped[str] = mapped_column(Text) image: Mapped[str] = mapped_column(String(255), nullable=True) - - @classmethod - def from_file(cls, path): - path = Path(path) - with path.open() as fp: - content = json.load(fp) - return cls(ident=path.name, **content) - - @classmethod - def get_all_schilder(cls, path: Path): - for f in path.glob("*.schild"): - yield cls.from_file(f) + template: Mapped[str] = mapped_column(String(255))