Ejemplo n.º 1
0
class Request(db.Model):
    id = db.Column(db.Interger, primary_key=True)
    user_id = db.Column(db.Interger, db.ForeingKey(users.id))
    user = db.Relationship('User', foreing_keys='user_id')
    food_id = db.Column(db.Interger, db.ForeingKey(foods.id))
    food = db.Relationship('Food', foreing_keys='food_id')

    def __int__(self, user_id, food_id):
        self.user_id = user_id
        self.food_id = food_id

    def __repr__(self):
        return "<Request %r>" % self.id
Ejemplo n.º 2
0
class Follow(db.Model):
    __tablename__ = "follow"
    id = db.Column(db.Integer, primary_key=True)
    id_user = db.Column(db.Integer, db.ForeingKey('users.id'))
    id_follower = db.Column(db.Integer, db.ForeingKey('users.id'))
    user = db.relationship('User', foreign_keys=id_user)
    follower = db.relationship('User', foreign_keys=id_follower)

    def __init__(self, content, id_user):
        self.content = content
        self.id_user = id_user

    def __repr__(self):  # representantion é tipo um to string
        return f"<Post {self.id} >"
Ejemplo n.º 3
0
class Subscriptions(db.Model):
    id = db.Column(db.Integer, primary_key=True, unique=True)
    subscribing_user = db.Column(db.String, db.ForeingKey('user.id'))
    subscribed_to_user = db.Column(db.String, db.ForeingKey('user.id'))
    begin_date = db.Column(db.DateTime, nullable=False)
    end_date = db.Column(db.DateTime, nullable=False)

    def create(self):
        db.session.add(self)
        db.session.commit()
        return self

    def __init__(self, subscribing_user, subscribed_to_user, begin_date,
                 end_date):
        self.subscribing_user = subscribing_user
        self.subscribed_to_user = subscribed_to_user
        self.begin_date = begin_date
        self.end_date = end_date

    def __repr__(self):
        return '' % self.id
Ejemplo n.º 4
0
class Post(db.Model):
    __tablename__ = 'posts'

    id = db.Column(db.Integer, primary_key=True)
    content = db.Column(db.Text)
    user_id = db.Column(db.Interger, db.ForeingKey('user.id'))

    user = db.relationship('User', foreing_keys=user_id)

    def __init__(self, content, user_id):
        self.content = content
        self.user_id = user_id

    def __repr__(self):
        return "<Post %r>" % self.id
Ejemplo n.º 5
0
class Personagem(db.Model):
    __tablename__ = "personagens"

    id = db.Column(db.Integer, primary_key=True)
    nome = db.Column(db.String(), unique=True)
    altura = db.Column(db.Integer, unique=True)
    peso = db.Column(db.Integer, unique=True)
    sexo = db.Column(db.String(), unique=True)
    anoDeNacimento = db.Column(db.String(), unique=True)
    especie_id = db.Column(db.Integer, db.ForeingKey('especies.id'))

    especie = db.relationship('Especie', ForeingKey=especie_id)

    def __repr__(self):
        return '<Personagem %r>' % self.nome
Ejemplo n.º 6
0
class Follow(db.Model):
    __tablename__ = 'follow'

    id = db.Column(db.Interger, primary_key=True)
    user_id = db.Column(db.Interger, db.ForeingKey('user_id'))
    follower_id = db.Column(db.Interger, unique=True)

    user = db.relationship('User', foreing_keys=user_id)
    follower = db.relationship('User', foreing_keys=follower_id)

    def __init__(self, user_id, follower_id):
        self.user_id = user_id
        self.follower_id = follower_id

    def __repr__(self):
        return "<Follow %r>" % self.user_id
Ejemplo n.º 7
0
from app import db

attendances = db.Table(
    "attendance",
    db.Column("userID", db.String, db.ForeignKey("user.id"), primary_key=True),
    db.Column("formID", db.Integer, db.ForeingKey("form.id"),
              primary_key=True))


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True),
    role = db.Column(db.String(35), unique=True, nullable=False),
    firstname = db.Column(db.String(25), nullable=False),
    lastname = db.Column(db.String(25), nullable=False),
    email = db.Column(db.String(35), nullable=False),
    phone = db.Column(db.String(35), nullable=True)

    attendances = db.relationship("Form",
                                  secondary=attendances,
                                  back_populates="users")


class Form(db.Model):
    id = db.Column(db.Integer, primary_key=True),
    name = db.Column(db.String(15), unique=True, nullable=False),
    sitepath = db.Column(db.String(21), unique=True, nullable=False)

    users = db.relationship("User",
                            secondary=attendances,
                            back_populates="attendances")