2020-08-11 13:17:53 +02:00
|
|
|
from oshipka.persistance import db, ModelController, index_service, LiberalBoolean, Ownable
|
2020-07-08 14:36:13 +02:00
|
|
|
|
2021-05-01 16:19:02 +02:00
|
|
|
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')),
|
|
|
|
)
|
|
|
|
|
2020-07-08 14:36:13 +02:00
|
|
|
|
2020-08-11 13:17:53 +02:00
|
|
|
class BlogPost(db.Model, ModelController, Ownable):
|
2020-07-08 14:36:13 +02:00
|
|
|
__searchable__ = ['body', ]
|
|
|
|
|
|
|
|
filename = db.Column(db.UnicodeText,)
|
2020-07-13 11:54:16 +02:00
|
|
|
title = db.Column(db.UnicodeText,)
|
2020-07-08 14:36:13 +02:00
|
|
|
body = db.Column(db.UnicodeText,)
|
2021-05-01 16:19:02 +02:00
|
|
|
tags = db.relationship('Tag', secondary=blog_post__tag,
|
|
|
|
backref=db.backref("blog_posts"),
|
|
|
|
)
|
|
|
|
|
|
|
|
_m_n_table_tags = 'Tag'
|
2020-08-11 13:17:53 +02:00
|
|
|
created_dt = db.Column(db.UnicodeText,)
|
|
|
|
updated_dt = db.Column(db.UnicodeText,)
|
2020-07-08 14:36:13 +02:00
|
|
|
|
2021-02-25 11:44:30 +01:00
|
|
|
def __repr__(self):
|
|
|
|
return "{} ({})".format(self.title, self.created_dt)
|
|
|
|
|
2020-07-08 14:36:13 +02:00
|
|
|
|
|
|
|
index_service.searchables.append(BlogPost)
|