Example #1
0
class Bid(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    bid_amount = db.Column(db.Integer)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User', backref=db.backref('bid', lazy='dynamic'))
    pet_id = db.Column(db.Integer, db.ForeignKey('pet.id'))
    pet = db.relationship('Pet', backref=db.backref('bid', lazy='dynamic'))

    def __init__(self, bid_amount, user, pet):
        self.bid_amount = bid_amount
        self.user = user
        self.pet = pet

    def __repr__(self):
        return '<Bid %r>' % self.bid_amount
Example #2
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_name = db.Column(db.String(80))

    role_id = db.Column(db.Integer, db.ForeignKey('role.id'))
    role = db.relationship('Role', backref=db.backref('users', lazy='dynamic'))

    def __init__(self, user_name, role):
        self.user_name = user_name
        self.role = role

    def __repr__(self):
        return '<User %r %r>' % self.user_name, self.role.role_name
Example #3
0
class AuthzWebAction(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    resource_name = db.Column(db.String(80))
    resource_action = db.Column(db.String(8))

    feature_id = db.Column(db.Integer, db.ForeignKey('authz_feature.id'))
    feature = db.relationship('AuthzFeature',
                              backref=db.backref('web_actions',
                                                 lazy='dynamic'))

    def __init__(self, resource_name, resource_action, feature):
        self.resource_name = resource_name
        self.resource_action = resource_action
        self.feature = feature

    def __repr__(self):
        return '<AuthzWebAction %r %r %r>' % self.resource_name, self.resource_action, self.feature.feature_name
Example #4
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80))
    body = db.Column(db.Text)
    pub_date = db.Column(db.DateTime)

    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    category = db.relationship('Category',
                               backref=db.backref('posts', lazy='dynamic'))

    def __init__(self, title, body, category, pub_date=None):
        self.title = title
        self.body = body
        if pub_date is None:
            pub_date = datetime.utcnow()
        self.pub_date = pub_date
        self.category = category

    def __repr__(self):
        return '<Post %r>' % self.title
Example #5
0
class Bid(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80))
    body = db.Column(db.Text)
    pub_date = db.Column(db.DateTime)

    vehicle_id = db.Column(db.Integer, db.ForeignKey('vehicle.id'))
    vehicle = db.relationship('Vehicle',
                              backref=db.backref('bids', lazy='dynamic'))

    def __init__(self, title, body, vehicle, pub_date=None):
        self.title = title
        self.body = body
        if pub_date is None:
            pub_date = datetime.utcnow()
        self.pub_date = pub_date
        self.vehicle = vehicle

    def __repr__(self):
        return '<Bid %r>' % self.title