Exemplo n.º 1
0
class Teacher(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    meta_id = db.Column(db.Integer, db.ForeignKey('meta.id'))
    meta = db.relationship("Meta", back_populates="teacher")

    def __repr__(self):
        return f"Teacher('{self.id}')"
Exemplo n.º 2
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text, nullable=True)
    email = db.Column(db.Text, unique=True, nullable=True)
    token = db.Column(db.Text, unique=True, nullable=True)
    github_access_token = db.Column(db.String(255), nullable=True)
    github_id = db.Column(db.Integer, nullable=True)
    github_username = db.Column(db.String(255), nullable=True)
    image = db.Column(db.Text, nullable=True)
    meta_id = db.Column(db.Integer, db.ForeignKey('meta.id'))
    meta = db.relationship("Meta", back_populates="user")

    def __repr__(self):
        return f"User('{self.email}')"
Exemplo n.º 3
0
class Meta(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    roles = db.Column(db.Text, nullable=True)
    user = db.relationship("User",
                           uselist=False,
                           cascade="all,delete",
                           back_populates="meta")
    admin = db.relationship("Admin",
                            uselist=False,
                            cascade="all,delete",
                            back_populates="meta")
    student = db.relationship("Student",
                              uselist=False,
                              cascade="all,delete",
                              back_populates="meta")
    teacher = db.relationship("Teacher",
                              uselist=False,
                              cascade="all,delete",
                              back_populates="meta")

    def __repr__(self):
        return f"Meta('{self.id}')"