33 lines
1.3 KiB
Python
33 lines
1.3 KiB
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', ]
|
|
|
|
_file_columns = []
|
|
|
|
model_acls = {'get': {'authn': False, 'authz': []}, 'list': {'authn': False, 'authz': []}, 'table': {'authn': False, 'authz': []}, 'search': {
|
|
'authn': False, 'authz': []}, 'create': {'authn': True, 'authz': ['admin']}, 'update': {'authn': True, 'authz': ['admin']}, 'delete': {'authn': True, 'authz': ['admin']}}
|
|
|
|
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)
|