コード例 #1
0
class EventKind(db.Model):
    __tablename__ = "event_kind"
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(50), index=True, nullable=False, unique=True)
    events = db.relationship("Event", backref="event_kind", cascade="all")

    def __repr__(self):
        return "{}".format(self.name)

    def set_kind(self, event):
        self.events.append(event)
コード例 #2
0
class Workplace(db.Model):
    __tablename__ = "workplace"
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(50), index=True, unique=True)
    workers = db.relationship("Worker", backref="workplace", cascade="all")

    def __repr__(self):
        return "{}".format(self.name)

    def set_workplace(self, worker):
        self.workers.append(worker)
コード例 #3
0
class User(db.Model, UserMixin):
    __tablename__ = "user"
    id = db.Column(db.Integer(), primary_key=True)
    username = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.Column(db.String(128))
    roles = db.relationship("Role", secondary="user_roles")

    def __repr__(self):
        return "{}".format(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)

    def assign_role(self, role):
        self.roles.append(role)
コード例 #4
0
class StartDoc(db.Model):
    __tablename__ = "start_docs"
    id = db.Column(db.Integer(), primary_key=True)
    notes = db.Column(db.String(300), default="")
    delivered = db.Column(db.Boolean(), default=False)
    sent_to_hr = db.Column(db.Boolean(), default=False)
    sent_date = db.Column(db.Date(), index=True)
    start_doc_type = db.Column(db.Integer, db.ForeignKey("start_doc_type.id"))
    worker_id = db.Column(db.Integer(), db.ForeignKey("worker.id"))

    def __repr__(self):
        return "{}".format(
            StartDocType.query.filter_by(id=self.start_doc_type).first())