class Listing(db.Model):

    # Columns
    type = db.Column(
      db.Enum(ListingTypes),
      nullable=False,
      primary_key=True
    )
    user_id = db.Column(
      db.Integer,
      db.ForeignKey('user.id'),
      nullable=False,
      primary_key=True
    )
    message_id = db.Column(
      db.Integer,
      db.ForeignKey('message.id'),
      nullable=False,
      primary_key=True
    )

    # Relations
    user = db.relationship(
      "User",
      foreign_keys=user_id,
      backref='listings'
    )
    message = db.relationship(
      "Message",
      foreign_keys=message_id,
      backref='listings'
    )
Beispiel #2
0
class State(db.Model):
    __tablename__ = 'state'
    id = db.Column(db.Integer, primary_key=True)
    describe = db.Column(db.Enum('停用', '启用'))  # 状态

    # material_id=db.Column(db.Integer,db.ForeignKey('material.id'))
    def __repr__(self):
        return '< State {} >'.format(self.describe)
Beispiel #3
0
class Package(db.Model):
    __tablename__ = 'package'
    id = db.Column(db.Integer, primary_key=True)
    describe = db.Column(
        db.Enum('千克', '件', '托', '箱', '只', '支', '组', '卷', '立方米', '平方米'))  #包装方式

    # material_id=db.Column(db.Integer,db.ForeignKey('material.id'))
    def __repr__(self):
        return '< Package {} >'.format(self.describe)
Beispiel #4
0
class Message(db.Model):
    __tablename__ = "messages"
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(100))
    last_name = db.Column(db.String(100))
    email = db.Column(db.String(50))
    city_id = db.Column(db.Integer, nullable=True)
    state_id = db.Column(db.Integer, nullable=True)
    message_type = db.Column(db.Enum('Pregunta', 'Cotizacion'))
    body = db.Column(db.Text)
    date_recieved = db.Column(db.String(100))
Beispiel #5
0
class Transacao(db.Model):
    __tablename__ = "transacao"

    id = db.Column(db.Integer, primary_key=True, autoincrement=True, nullable=False)
    titulo = db.Column(db.String(50), nullable=False)
    descricao = db.Column(db.String(100), nullable=False)
    valor = db.Column(db.Float, nullable=False)
    tipo = db.Column(db.Enum(TipoEnum), nullable=False)
    data = db.Column(db.Date, nullable=False)
    conta_id = db.Column(db.Integer, db.ForeignKey("conta.id"))
    conta = db.relationship("Conta", backref=db.backref("transacoes", lazy="dynamic"))
Beispiel #6
0
class UserPlant(BaseModel, Model):
    __tablename__ = 'user_plant'
    plant_id = Column(db.ForeignKey('plant.id'), comment="植物id")
    user_id = Column(db.ForeignKey('user.id'), comment="用户id")
    active_flag = Column(db.Boolean(), server_default=db.text("True"), comment="是否启用,True启用 False不启用", index=True)
    water = Column(db.Integer(), comment='水分')
    fertilizer = Column(db.Integer(), comment='肥料')
    pesticide = Column(db.Integer(), comment='药')
    price = Column(db.Numeric(4, 2), comment='价值')
    harvest_at = Column(db.Date(), comment='预计收获时间')
    status = Column(db.Enum(PlantStatus), comment='状态')
    image = Column(db.String(1024), comment='图片')
Beispiel #7
0
class Ingredient(db.Model):
    """ Ingredient model for storing ingredients and their details """

    __tablename__ = 'ingredients'

    id = db.Column(UUID(as_uuid=True),
                   primary_key=True,
                   default=lambda: uuid.uuid4().hex)
    name = db.Column(db.String(255), unique=True, nullable=False)
    measurement = db.Column(db.Enum(MeasurementEnum), nullable=False)
    category = db.Column(db.Enum(CategoryEnum), nullable=False)

    users = association_proxy('ingredient_users', 'user')
    recipes = association_proxy('ingredient_recipes', 'recipe')

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

    def __repr__(self):
        return '<Ingredient %s>' % self.name
Beispiel #8
0
class Books(db.Model):
    __tablename__ = 'books'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(64), unique=True, nullable=False)
    category = db.Column(db.String(64), unique=True)
    price = db.Column(db.Float)
    user_id = db.Column(db.Float)
    status = db.Column(db.Enum('0', '1'), default='1')

    def to_dict(self):
        return {
            'name': self.name,
            'category': self.category,
            'price': self.price
        }
Beispiel #9
0
class Wallet(db.Model):
    wallet_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), unique=True, nullable=False)
    currency = db.Column(db.Enum(CurrencyUnit), nullable=False)

    def to_dict(self):
        return {
            "id": self.wallet_id,
            "name": self.name,
            "currency": self.__assign_correct_currency(),
            "coins": [coin.to_dict(self.currency) for coin in self.coins]
        }

    def __assign_correct_currency(self):
        if self.currency == CurrencyUnit.USD:
            return "USD"
        elif self.currency == CurrencyUnit.PEN:
            return "PEN"
        elif self.currency == CurrencyUnit.EUR:
            return "EUR"
Beispiel #10
0
class Storage(BaseModel, Model):
    __tablename__ = 'storage'
    user_id = Column(db.ForeignKey('user.id'), comment='用户id')
    item_type = Column(db.Enum(ItemType), comment='物品类型')
    item_id = Column(db.ForeignKey('seed.id'), comment='物品ou o')
    quantity = Column(db.Integer(5), comment='数量')