예제 #1
0
class Project(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False, unique=True)
    shortcut = db.Column(db.String(50), nullable=False, unique=True)
    start_date = db.Column(db.String(50), nullable=False, default=func.current_date())
    end_date = db.Column(db.String(50), nullable=False)
    phase = db.Column(db.String(50), nullable=False)
    active = db.Column(db.Boolean, default=True)
    hour = db.relationship("Hour", backref="project", passive_deletes=True)

    def __repr__(self):
        return f"Project: {self.name}"
예제 #2
0
class Todo(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(256), nullable=False)
    description = db.Column(db.Text, nullable=False)
    date_created = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    date_completed = db.Column(db.DateTime, nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    user = db.relationship('User', backref=db.backref('todos', lazy=True))

    def __repr__(self):
        return f"Description: '{self.description}', Date: '{self.date_created}'"
예제 #3
0
class Timesheet(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, nullable=False, default=datetime.now)
    workhours = db.Column(db.Numeric(5, 1), nullable=False)
    description = db.Column(db.Text, nullable=True)
    date_created = db.Column(db.DateTime, nullable=False, default=datetime.now)
    date_updated = db.Column(db.DateTime, nullable=True)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    user = db.relationship('User', backref=db.backref('timesheets', lazy=True))
    subject_id = db.Column(db.Integer,
                           db.ForeignKey('subject.id'),
                           nullable=False)
    subject = db.relationship('Subject',
                              backref=db.backref('timesheets', lazy=True))
    task_id = db.Column(db.Integer, db.ForeignKey('task.id'), nullable=True)
    task = db.relationship('Task', backref=db.backref('timesheets', lazy=True))

    def __repr__(self):
        if self.task:
            return f"Timesheet('{self.subject.name}', '{self.task.name}', '{self.date_created}', '{self.hours}')"
        else:
            return f"Timesheet('{self.subject.name}', '{self.date_created}', '{self.hours}')"
예제 #4
0
class Subject(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(126), nullable=False)
    description = db.Column(db.Text, nullable=False)
    date_created = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    active = db.Column(db.Boolean, nullable=False, default=True)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    user = db.relationship('User', backref=db.backref('subjects', lazy=True))

    def __repr__(self):
        return f"Name: '{self.name}', Date: '{self.date_created}'"
예제 #5
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(100), nullable=False, unique=True)
    password_hash = db.Column(db.String(50))
    total_vacation_days = db.Column(db.Integer, default=0)
    rem_vacation_days = db.Column(db.Integer, default=0)
    hour = db.relationship("Hour", backref="user", passive_deletes=True)
    vacation = db.relationship("Vacation",
                               backref="user",
                               passive_deletes=True)

    def __repr__(self):
        return f"{self.username}"

    @property
    def password(self):
        raise AttributeError("password is not a readable attribute")

    @password.setter
    def password(self, password):
        self.password_hash = generate_password_hash(password)

    def verify_password(self, password):
        return check_password_hash(self.password_hash, password)