Ejemplo n.º 1
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(50), nullable=False)
    password_hash = db.Column(db.String(255), nullable=False)
    created_at = db.Column(db.DateTime, nullable=False, default=datetime.now)
    updated_at = db.Column(db.DateTime, nullable=False, default=datetime.now, onupdate=datetime.now)
    group_id = db.Column(db.Integer, db.ForeignKey('groups.id'), nullable=False)

    attendanceLog = db.relationship('AttendanceLog', backref='users', lazy=True)
    notification = db.relationship('Notification', backref='users', lazy=True)

    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)

    def __init__(self, name, password, attendance_log, notification):
        self.name = name
        self.set_password(password)
        self.attendanceLog = attendance_log
        self.notification = notification

    def __repr__(self):
        return '<User %r>' % self.name
Ejemplo n.º 2
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    created_at = db.Column(db.DateTime, nullable=False, default=datetime.now)
    updated_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now,
                           onupdate=datetime.now)
Ejemplo n.º 3
0
class AttendanceStatus(db.Model):
    __tablename__ = 'status'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    group_id = db.Column(db.Integer, db.ForeignKey('groups.id'), nullable=False)
    status = db.Column(db.String(255), nullable=False)

    def __init__(self, status):
        self.status = status

    def __repr__(self):
        return '<AttendanceStatus %r>' % self.status
Ejemplo n.º 4
0
class Notification(db.Model):
    __tablename__ = 'notifications'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    group_id = db.Column(db.Integer, db.ForeignKey('groups.id'), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    content = db.Column(db.String(255), nullable=False)
    recorded_at = db.Column(db.DateTime, nullable=False, default=datetime.now)

    def __init__(self, content):
        self.content = content

    def __repr__(self):
        return '<Notification %r>' % self.content
Ejemplo n.º 5
0
class Group(db.Model):
    __tablename__ = 'groups'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(50), nullable=False)
    # boss_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    user = db.relationship('User', backref='groups', lazy=True)
    notification = db.relationship('Notification', backref='groups', lazy=True)
    status = db.relationship('AttendanceStatus', backref='groups', lazy=True)

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

    def __repr__(self):
        return '<Group %r>' % self.name