Ejemplo n.º 1
0
class Starter(db.Model):
    id = db.Column(db.Integer, db.ForeignKey('food.id'), primary_key=True)
    name = db.Column(db.String(100), nullable=False)

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return 'Starter {0}, name {1}'.format(self.id, self.name)
Ejemplo n.º 2
0
class Ingredient(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return 'Ingredient {0}, name {1}'.format(self.id, self.name)
Ejemplo n.º 3
0
class Dinner(db.Model):
    id = db.Column(db.Integer, db.ForeignKey('food.id'), primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    days = db.Column(db.Integer, default=1)
    related_lunch = db.relationship('Lunch', uselist=False, backref='dinner', lazy='select')

    def __init__(self, name, days=1):
        self.name = name
        self.days = days

    def __repr__(self):
        return 'Dinner {0}, name {1}'.format(self.id, self.name)
Ejemplo n.º 4
0
class Menu(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=True)
    daily_menus = db.relationship('DailyMenu', backref='menu', lazy='select')
    favourite = db.Column(db.Boolean, server_default=expression.false())
    created_at = db.Column(db.DateTime(timezone=True), server_default=func.now())

    def __init__(self, name=None, favourite=False):
        self.name = name
        self.favourite = favourite

    def __repr__(self):
        return 'Menu {0}, name {1}, created at {2}'.format(self.id, self.name, self.created_at)
Ejemplo n.º 5
0
class Lunch(db.Model):
    id = db.Column(db.Integer, db.ForeignKey('food.id'), primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    days = db.Column(db.Integer, default=1)
    need_starter = db.Column(db.Boolean, server_default=expression.false())
    related_dinner_id = db.Column(db.Integer, db.ForeignKey('dinner.id'), nullable=True)

    def __init__(self, name, days=1, need_starter=False, related_dinner_id=None):
        self.name = name
        self.days = days
        self.need_starter = need_starter
        self.related_dinner_id = related_dinner_id

    def __repr__(self):
        return 'Lunch {0}, name {1}'.format(self.id, self.name)