Aug 4 - Update code to follow up - MT13b
This commit is contained in:
@@ -81,11 +81,33 @@ class Inspection(db.Model):
|
||||
)
|
||||
follow_up_required = db.Column(db.Boolean, nullable=False, default=False)
|
||||
follow_up_note = db.Column(db.Text, nullable=True)
|
||||
# phase49 — WHO asked for the follow-up and when. `follow_up_required` alone
|
||||
# cannot distinguish a client request from an internal one, and staff need to
|
||||
# know who is waiting. Set by flag_followup(), nulled by clear_followup().
|
||||
# NULL on every pre-phase49 row, which the UI renders as an unattributed
|
||||
# follow-up exactly as before.
|
||||
follow_up_requested_by = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('users.id', ondelete='SET NULL',
|
||||
name='fk_inspections_follow_up_requested_by'),
|
||||
nullable=True,
|
||||
)
|
||||
follow_up_requested_at = db.Column(db.DateTime, nullable=True)
|
||||
|
||||
results = db.relationship('InspectionResult', backref='inspection', lazy='dynamic', cascade='all, delete-orphan')
|
||||
issues = db.relationship('Issue', backref='inspection', lazy='dynamic', cascade='all, delete-orphan')
|
||||
follow_ups = db.relationship('Inspection', backref=db.backref('parent', remote_side='Inspection.id'),
|
||||
lazy='dynamic', foreign_keys='Inspection.parent_inspection_id')
|
||||
# phase49. Explicit foreign_keys is required: inspector_id also points at
|
||||
# users.id, so SQLAlchemy cannot infer which column this relationship uses.
|
||||
follow_up_requester = db.relationship('User',
|
||||
foreign_keys=[follow_up_requested_by])
|
||||
# The schedule this inspection was started from / materialised by, so the
|
||||
# detail view can show the cadence and who set it up. Explicit foreign_keys
|
||||
# again: inspection_schedules.parent_inspection_id points back here (phase48),
|
||||
# so neither side's join is inferable.
|
||||
inspection_schedule = db.relationship(
|
||||
'InspectionSchedule', foreign_keys=[inspection_schedule_id])
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Inspection {self.id} - {self.inspection_date}>'
|
||||
|
||||
Reference in New Issue
Block a user