예제 #1
0
class Passport(db.Model):
  __tablename__ = "db_passport"
  id = db.Column(db.Integer, autoincrement=True, primary_key=True)
  stamps = db.Column(db.Float, default=0.0, nullable=False)
  donations = db.Column(db.Float, default=0.0, nullable=False)
  activated = db.Column(db.Boolean, default=False, nullable=False)
  recharged = db.Column(db.Boolean, default=False, nullable=False)
  user_id = db.Column(db.Integer, db.ForeignKey('db_user.id'))
  event_id = db.Column(db.Integer, db.ForeignKey('db_event.id'))
  amount_recharged = db.Column(db.Float, default=0.0, nullable=True)
  recharged_by = db.Column(db.Integer, db.ForeignKey('db_user.id'), nullable=True)
  user = db.relation(User, foreign_keys=[user_id] ,backref='passports')  
  event = db.relation(Event, backref='passports')  
  recharger = db.relation(User, foreign_keys=[recharged_by], backref='recharged_passports')
예제 #2
0
class Group(db.Model):
    __tablename__ = 'db_group'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    name = db.Column(db.String(32), unique=True, nullable=False)
    users = db.relation('User', secondary=user_group_table, backref='groups')

    def __repr__(self):
        return '%r' % self.name
예제 #3
0
class Permission(db.Model):
    __tablename__ = 'db_permission'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    name = db.Column(db.String(32), unique=True, nullable=False)
    # description = Column(Unicode(255))
    groups = db.relation(Group,
                         secondary=group_permission_table,
                         backref='permissions')

    def __repr__(self):
        return '%r' % self.name
예제 #4
0
class Product(db.Model):
    __tablename__ = "db_product"
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    vendor_id = db.Column(db.Integer, db.ForeignKey('db_vendor.id'))
    name = db.Column(db.String(42), nullable=False)
    price = db.Column(db.Float, nullable=False)
    vendor = db.relation(Vendor, backref='products')
    purchases = db.relationship('Purchase',
                                secondary=product_purchase_table,
                                back_populates="products")

    def __repr__(self):
        return self.name
예제 #5
0
class Vendor(db.Model):
    __tablename__ = "db_vendor"
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('db_user.id'),
                        nullable=False)
    user = db.relation(User, backref='vendor')
    name = db.Column(db.String(42), nullable=False)
    isFoundation = db.Column(db.Boolean, default=False, nullable=False)
    events = db.relationship(Event, secondary=vendor_event_table)

    def __repr__(self):
        return self.name
예제 #6
0
class Purchase(db.Model):
    __tablename__ = "db_purchase"
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    donation = db.Column(db.Boolean, default=False, nullable=False)
    passport_id = db.Column(db.Integer,
                            db.ForeignKey('db_passport.id'),
                            nullable=False)
    passport = db.relation(Passport, backref='purchases')
    id_client = db.Column(db.Integer, nullable=True)
    price = db.Column(db.Float, nullable=False)
    datetime = db.Column(db.DateTime, default=datetime.datetime.now())
    products = db.relationship('Product', secondary=product_purchase_table)
    vendor_id = db.Column(db.Integer,
                          db.ForeignKey('db_vendor.id'),
                          nullable=False)
    vendor = db.relation(Vendor, backref='purchases')

    def __repr__(self):
        return str(self.products)


# La clave primaria de esta clase es compuesta

#participateIn