class Titelbild now has an additional _asdict_with_urls() method returning endpoint URLs instead of blobs
This commit is contained in:
parent
68d64bed73
commit
25616ca5a2
@ -1,6 +1,7 @@
|
|||||||
from the_works.database import db
|
from the_works.database import db
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
from sqlalchemy.ext.associationproxy import association_proxy
|
||||||
|
from flask import url_for
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# add method to sqlalchemy.orm.decl_api.Model
|
# add method to sqlalchemy.orm.decl_api.Model
|
||||||
@ -87,6 +88,12 @@ class Titelbild(db.Model):
|
|||||||
__table__ = db.Model.metadata.tables['Titelbild']
|
__table__ = db.Model.metadata.tables['Titelbild']
|
||||||
werk = relationship("Werk", back_populates="titelbild")
|
werk = relationship("Werk", back_populates="titelbild")
|
||||||
|
|
||||||
|
def _asdict_with_urls(self):
|
||||||
|
tb = self._asdict()
|
||||||
|
tb["Bild"] = url_for("titelbild.image", id=self.ID)
|
||||||
|
tb["Thumbnail"] = url_for("titelbild.thumbnail", id=self.ID)
|
||||||
|
return tb
|
||||||
|
|
||||||
class Text_Genre(db.Model):
|
class Text_Genre(db.Model):
|
||||||
__table__ = db.Model.metadata.tables['Text_Genre']
|
__table__ = db.Model.metadata.tables['Text_Genre']
|
||||||
text = relationship("Text", back_populates="text_genre")
|
text = relationship("Text", back_populates="text_genre")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user