oshipka/vm_gen/templates/model_acl_py

22 lines
998 B
Plaintext
Raw Normal View History

2021-05-09 00:05:26 +02:00
from sqlalchemy_utils import ChoiceType
from oshipka.persistance import db, ModelController
from oshipka.persistance import SHARING_TYPE_TYPES, SHARING_TYPE_TYPES_TYPE_PUBLIC
class [[ name ]]Acl(db.Model, ModelController):
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
user = db.relationship('User', backref=db.backref("[[ name|camel_to_snake ]]_acls"))
instance_id = db.Column(db.Integer, db.ForeignKey('[[ name|camel_to_snake ]].id'))
instance = db.relationship('[[ name ]]', backref=db.backref("[[ name|camel_to_snake|pluralize ]]"))
acl_type = db.Column(ChoiceType(SHARING_TYPE_TYPES), default=SHARING_TYPE_TYPES_TYPE_PUBLIC)
_read = db.Column(db.Boolean, default=True)
_update = db.Column(db.Boolean, default=True)
_delete = db.Column(db.Boolean, default=True)
[% for column in columns %]
[[ column.name ]]__read = db.Column(db.Boolean, default=True)
[[ column.name ]]__write = db.Column(db.Boolean, default=True)
[%- endfor %]