feat: complete requirements gaps - backup/restore, uat signoff, pm attachments, templates, and filters

This commit is contained in:
Atharv1705
2026-11-13 18:15:32 +05:30
parent cd9eb27a98
commit d9ca4bbb02
38 changed files with 1403 additions and 69 deletions
@@ -15,6 +15,8 @@ from ..models import (
Contract,
DemoEquipment,
InsurancePolicy,
PMRecord,
PMSchedule,
User,
Warranty,
)
@@ -29,6 +31,7 @@ ALLOWED_ENTITY_TYPES: set[str] = {
"demo_equipment",
"asset",
"warranty",
"pm_record",
}
EXT_TO_MIME: dict[str, str] = {
@@ -50,6 +53,7 @@ COORDINATOR_UPLOAD_ENTITIES: set[str] = {
"insurance",
"warranty",
"demo_equipment",
"pm_record",
}
@@ -128,6 +132,17 @@ def resolve_entity_department_id(db: Session, entity_type: str, entity_id: int)
raise CodedHTTPException(status_code=404, detail="Calibration record not found.", code="NOT_FOUND")
return obj.asset.department_id
if entity_type == "pm_record":
obj = (
db.query(PMRecord)
.options(joinedload(PMRecord.schedule).joinedload(PMSchedule.asset))
.filter(PMRecord.id == entity_id)
.first()
)
if obj is None:
raise CodedHTTPException(status_code=404, detail="PM record not found.", code="NOT_FOUND")
return obj.schedule.asset.department_id
raise CodedHTTPException(status_code=400, detail="Unsupported entity_type.", code="INVALID_ENTITY_TYPE")