blog/webapp/models/_blog_post.py
2021-05-01 16:19:02 +02:00

28 lines
953 B
Python

from oshipka.persistance import db, ModelController, index_service, LiberalBoolean, Ownable
blog_post__tag = db.Table('blog_post__tag',
db.Column('blog_post_id', db.Integer(), db.ForeignKey('blog_post.id')),
db.Column('tag_id', db.Integer(), db.ForeignKey('tag.id')),
)
class BlogPost(db.Model, ModelController, Ownable):
__searchable__ = ['body', ]
filename = db.Column(db.UnicodeText,)
title = db.Column(db.UnicodeText,)
body = db.Column(db.UnicodeText,)
tags = db.relationship('Tag', secondary=blog_post__tag,
backref=db.backref("blog_posts"),
)
_m_n_table_tags = 'Tag'
created_dt = db.Column(db.UnicodeText,)
updated_dt = db.Column(db.UnicodeText,)
def __repr__(self):
return "{} ({})".format(self.title, self.created_dt)
index_service.searchables.append(BlogPost)