politikorama/app/model/representative_origin.py

22 lines
702 B
Python

# encoding: utf-8
from app import admin, db
from app.model.model import Model, View
class RepresentativeOriginModel(db.Model, Model):
__tablename__ = "representative_origin"
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("references", lazy="dynamic")
)
source_id = db.Column(db.Integer, db.ForeignKey("source.id"))
source = db.relationship("SourceModel")
reference = db.Column(db.String(200))
admin.add_view(View(
RepresentativeOriginModel, db.session, name="RepresentativeOrigin", category="CRUD"
))