Jul 8 - Implement issue assignment separation

This commit is contained in:
2026-07-08 13:56:25 -04:00
parent 39feaa4704
commit b06d939ac0
7 changed files with 287 additions and 35 deletions
+23
View File
@@ -84,6 +84,18 @@ class Issue(db.Model):
vendor_contact = db.Column(db.String(200), nullable=True) # phone or email
vendor_notes = db.Column(db.Text, nullable=True)
# ── Who handles the issue (phase35) ──────────────────────────────────
# internal = our staff (assigned_to); facility = the facility's own staff
# (facility_handler_* below); vendor = external contractor (vendor_* above).
# assigned_to remains the internal follow-up owner in ALL cases.
handler_type = db.Column(
db.Enum('internal', 'facility', 'vendor'),
nullable=False, default='internal',
)
facility_handler_name = db.Column(db.String(100), nullable=True)
facility_handler_contact = db.Column(db.String(200), nullable=True) # phone or email
facility_handler_notes = db.Column(db.Text, nullable=True)
# Relationships
# NOTE: Issue.area is provided by the backref on Area.issues (facility.py).
# Do NOT add a second explicit db.relationship('Area') here — it conflicts
@@ -102,6 +114,17 @@ class Issue(db.Model):
"""Return True if the given user is currently following this issue."""
return self.followers.filter_by(user_id=user.id).first() is not None
# Human-readable label for the handler category (phase35).
HANDLER_LABELS = {
'internal': 'Our Staff',
'facility': 'Facility Staff',
'vendor': 'External Vendor',
}
@property
def handler_label(self):
return self.HANDLER_LABELS.get(self.handler_type or 'internal', 'Our Staff')
@property
def resolved_facility(self):
"""Returns the Facility for this issue regardless of which path was used to create it.