30 lines
920 B
Python
30 lines
920 B
Python
# encoding: utf-8
|
|
|
|
from app import admin, db
|
|
from app.model.model import Model, View
|
|
|
|
|
|
class DecisionModel(db.Model, Model):
|
|
__tablename__ = "decision"
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
representative_id = db.Column(db.Integer, db.ForeignKey("representative.id"))
|
|
representative = db.relationship(
|
|
"RepresentativeModel", backref=db.backref("decisions", lazy="dynamic")
|
|
)
|
|
recommendation_id = db.Column(db.Integer, db.ForeignKey("recommendation.id"))
|
|
recommendation = db.relationship(
|
|
"RecommendationModel", backref=db.backref("decisions", lazy="dynamic")
|
|
)
|
|
value = db.Column(db.String(200))
|
|
|
|
def __repr__(self):
|
|
return self.value
|
|
|
|
|
|
class AdminView(View):
|
|
column_default_sort = "value"
|
|
column_filters = ["representative.name", "recommendation.name"]
|
|
|
|
|
|
admin.add_view(AdminView(DecisionModel, db.session, name="Decision", category="CRUD"))
|