Beispiel #1
0
class MenuSection(UserSubmitted, Record, BASE):
    __tablename__ = 'menusections'
    restaurant_id = db.Column(
        db.Integer,
        db.ForeignKey("restaurants.id", ondelete='CASCADE'),
        nullable=False,
        primary_key=True,
        autoincrement=False)
    name = db.Column(db.String, nullable=False, primary_key=True)
Beispiel #2
0
class Record:
    created_at = db.Column(
        db.DateTime, default=datetime.datetime.utcnow, nullable=False)
    updated_at = db.Column(
        db.DateTime,
        default=datetime.datetime.utcnow,
        nullable=False,
        onupdate=datetime.datetime.utcnow,
    )
Beispiel #3
0
class Amendment(UserSubmitted, Record, BASE):
    __tablename__ = 'amendments'
    id = db.Column(
        db.Integer, primary_key=True, autoincrement=True, nullable=False)
    reason = db.Column(db.String, nullable=False)
    identifier = db.Column(db.String, nullable=False)
    specifics = db.Column(db.String, nullable=True)
    amendment_type = db.Column(
        db.Enum(AmendmentType),
        nullable=False,
        default=AmendmentType.amendment)
Beispiel #4
0
class MenuItem(UserSubmitted, Record, BASE):
    __tablename__ = 'menuitems'
    restaurant_id = db.Column(
        db.Integer,
        db.ForeignKey("restaurants.id", ondelete='CASCADE'),
        nullable=False,
        primary_key=True,
        autoincrement=False)
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String, nullable=False)
    description = db.Column(db.String, nullable=True)
    price = db.Column(db.Float, nullable=True)
    section = relationship('MenuSectionAssignment', lazy='joined')
Beispiel #5
0
class MenuSectionAssignment(UserSubmitted, Record, BASE):
    __tablename__ = 'menusectionassignemnts'
    restaurant_id = db.Column(db.Integer, primary_key=True, nullable=False)
    section_name = db.Column(db.String, primary_key=True, nullable=False)
    menu_item_id = db.Column(db.Integer, primary_key=True, nullable=False)
    __table_args__ = (db.ForeignKeyConstraint(
        [menu_item_id, restaurant_id], [MenuItem.id, MenuItem.restaurant_id],
        ondelete='CASCADE'),
                      db.ForeignKeyConstraint(
                          [section_name, restaurant_id],
                          [MenuSection.name, MenuSection.restaurant_id],
                          ondelete='CASCADE',
                          onupdate='CASCADE'))
Beispiel #6
0
class UserSubmitted:
    request_uuid = db.Column(
        db.String, default=(lambda _: g.request_uuid), nullable=False)

    @declared_attr
    def submitter_id(cls):
        return db.Column(db.String, db.ForeignKey("fbusers.id"), nullable=True)
Beispiel #7
0
class ItemImage(UserSubmitted, Record, BASE):
    __tablename__ = 'itemimages'
    link = db.Column(db.String, primary_key=True, nullable=False)
    restaurant_id = db.Column(db.Integer, primary_key=True, nullable=False)
    menu_item_id = db.Column(db.Integer, primary_key=True, nullable=False)
    description = db.Column(db.String, nullable=True)
    approval_status = db.Column(
        db.Enum(ApprovalStatus),
        default=
        (lambda _: ApprovalStatus.approved if g.is_admin else ApprovalStatus.pending
         ),
        nullable=False)

    __table_args__ = (db.ForeignKeyConstraint(
        (menu_item_id, restaurant_id), (MenuItem.id, MenuItem.restaurant_id),
        ondelete='CASCADE'), )
Beispiel #8
0
class Restaurant(UserSubmitted, Record, BASE):
    __tablename__ = 'restaurants'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String, nullable=False)
    longitude = db.Column(db.Float, nullable=False)
    latitude = db.Column(db.Float, nullable=False)
    description = db.Column(db.String, nullable=True)
    website = db.Column(db.String, nullable=True)
    phone_number = db.Column(db.String, nullable=True)
    cuisine_type = db.Column(db.String, nullable=True)
    approval_status = db.Column(
        db.Enum(ApprovalStatus),
        default=
        (lambda _: ApprovalStatus.approved if g.is_admin else ApprovalStatus.pending
         ),
        nullable=False)
Beispiel #9
0
class FBUser(Record, BASE):
    __tablename__ = 'fbusers'
    id = db.Column(db.String, nullable=False, primary_key=True)
    name = db.Column(db.String, nullable=False)
    profile_url = db.Column(db.String, nullable=False)
    access_token = db.Column(db.String, nullable=False)
    amazon_code = db.Column(db.String, nullable=True)
    points = db.Column(db.Integer, nullable=False, default=0)
    last_reward_points = db.Column(db.Integer, nullable=False, default=0)
    submitted_restaurants = relationship('Restaurant', lazy='select')
    submitted_menu_sections = relationship('MenuSection', lazy='select')
    submitted_items = relationship('MenuItem', lazy='select')
    submitted_item_images = relationship('ItemImage', lazy='select')
Beispiel #10
0
 def submitter_id(cls):
     return db.Column(db.String, db.ForeignKey("fbusers.id"), nullable=True)
Beispiel #11
0
class Blob(Record, BASE):
    __tablename__ = 'blobs'
    key = db.Column(db.String, nullable=False, primary_key=True)
    data = db.Column(db.String, nullable=False)