Esempio n. 1
0
class PersonNotes(db.Model):
    __tablename__ = 'people_note'

    person_id = db.Column(db.Integer, db.ForeignKey('people.unique_id'), primary_key=True)
    note = db.Column(db.Text())

    def __str__(self):
        return 'Person(person_id={}, note={}'.format(self.person_id, self.note)

    def __repr__(self):
        return str(self)

    @staticmethod
    def update() -> None:
        db.session.commit()

    def add(self) -> None:
        db.session.add(self)
        db.session.commit()

    def delete(self) -> None:
        db.session.delete(self)
        db.session.commit()

    def to_json_str(self) -> str:
        return self.note
Esempio n. 2
0
class PersonPhone(db.Model):
    __tablename__ = 'person_phone'

    unique_id = db.Column(db.Integer(), primary_key=True)
    person_id = db.Column(db.Integer(), db.ForeignKey('people.unique_id'))
    phone_number = db.Column(db.Integer())
    type = db.Column(db.String(15))

    def __str__(self):
        return 'PersonPhone(unique_id={}, person_id={}, phone_number={}, type={}' \
            .format(self.unique_id, self.person_id, self.phone_number, self.type)

    def __repr__(self):
        return str(self)

    @staticmethod
    def update() -> None:
        db.session.commit()

    def add(self) -> None:
        db.session.add(self)
        db.session.commit()

    def delete(self) -> None:
        db.session.delete(self)
        db.session.commit()

    def to_json(self):
        return {
            'unique_id': self.unique_id,
            'person_id': self.person_id,
            'phone_number': self.phone_number,
            'type': self.type,
        }
Esempio n. 3
0
class PersonWork(db.Model):
    __tablename__ = 'people_work'

    person_id = db.Column(db.Integer,
                          db.ForeignKey('people.unique_id'),
                          primary_key=True)
    occupation = db.Column(db.String(50))
    occupation_start = db.Column(db.Date())
    employer = db.Column(db.String(50))
    employer_start = db.Column(db.Date())
    level_of_education = db.Column(db.String(20))

    def add(self) -> None:
        db.session.add(self)
        db.session.commit()

    def delete(self) -> None:
        db.session.delete(self)
        db.session.commit()

    def to_json(self) -> dict:
        return {
            'person_id': self.person_id,
            'occupation': self.occupation,
            'occupation_start': self.occupation_start,
            'employer': self.employer,
            'employer_start': self.employer_start,
            'level_of_education': self.level_of_education
        }
Esempio n. 4
0
class PersonDrivingAccident(db.Model):
    __tablename__ = 'person_driving_accident'

    unique_id = db.Column(db.Integer(), primary_key=True)
    person_id = db.Column(db.Integer(), db.ForeignKey('people.unique_id'))
    percent_fault = db.Column(db.Numeric(3))
    date_occurred = db.Column(db.Date())
    injuries = db.Column(db.Integer())
    description = db.Column(db.Text())
    paid_by = db.Column(db.String(70))

    def __str__(self):
        return 'Person(unique_id={}, person_id={}, date_received={}, date_convicted={}, type={}' \
            .format(self.unique_id, self.person_id, self.date_received, self.date_convicted, self.type)

    def __repr__(self):
        return str(self)

    @staticmethod
    def update() -> None:
        db.session.commit()

    def add(self) -> None:
        db.session.add(self)
        db.session.commit()

    def delete(self) -> None:
        db.session.delete(self)
        db.session.commit()

    def to_json(self) -> dict:
        return {
            'unique_id': self.unique_id,
            'person_id': self.person_id,
            'date_occurred': self.date_occurred,
            'percent_fault': self.percent_fault,
            'injuries': self.injuries,
            'description': self.description,
            'paid_by': self.paid_by
        }
Esempio n. 5
0
class PersonDrivingViolation(db.Model):
    __tablename__ = 'person_driving_violation'

    unique_id = db.Column(db.Integer(), primary_key=True)
    person_id = db.Column(db.Integer(), db.ForeignKey('people.unique_id'))
    date_received = db.Column(db.Date())
    date_convicted = db.Column(db.Date())
    type = db.Column(db.Text())

    def __str__(self):
        return 'Person(unique_id={}, person_id={}, date_received={}, date_convicted={}, type={}' \
            .format(self.unique_id, self.person_id, self.date_received, self.date_convicted, self.type)

    def __repr__(self):
        return str(self)

    @staticmethod
    def update() -> None:
        db.session.commit()

    def add(self) -> None:
        db.session.add(self)
        db.session.commit()

    def delete(self) -> None:
        db.session.delete(self)
        db.session.commit()

    def to_json(self) -> dict:
        return {
            'unique_id': self.unique_id,
            'person_id': self.person_id,
            'date_received': self.date_received,
            'date_convicted': self.date_convicted,
            'type': self.type
        }