Exemple #1
0
class Buffer(db.Model):
    __tablename__= 'buffer'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, index=True, nullable=False)
    event_tag = db.Column(db.String(2000), unique=True,
            index=True, nullable=False)     
    duration = db.Column(db.Integer) 
Exemple #2
0
class Tag(db.Model):
    __tablename__ = 'tag'

    id = db.Column(db.Integer, primary_key=True)
    tag_name = db.Column(db.String(200), index=True, unique=True,    
                 nullable=False)

    # Many-to-many for events-tags, defines a Event.tags attribute
    tags = db.relationship('Event', secondary=event_as, 
            backref='tags', lazy='dynamic')
Exemple #3
0
class User(db.Model, UserMixin):
    __tablename__ = 'user'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), index=True, unique=True, nullable=False)
    email = db.Column(db.String(120) ,index=True, unique=True, nullable=False)
    password_hash = db.Column(db.String(128), nullable=False)
    
    # Establish Rating objects on User called User.ratings.
    # Establish a .user attribute on Rating which referes to the parent User object
    ratings = db.relationship('Rating', backref='user', lazy='dynamic')

    def __repr__(self):
        return '{},{}'.format(self.id, self.username)

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
Exemple #4
0
class Event(db.Model):
    __tablename__ = 'event'

    id = db.Column(db.Integer, primary_key=True)
    duration = db.Column(db.Integer) 
    rating_date = db.Column(db.DateTime, index=True, nullable=False) 
    story = db.Column(db.String(2000), nullable=False, index=True)

    # Many-to-many for rating-events, defines an Rating.events attribute
    rating_events = db.relationship('Rating', secondary=rating_as,
                    backref='events', lazy='dynamic')