feat: add group management for workers and shifts, including validation for overlapping groups

This commit is contained in:
Ross
2026-07-09 22:14:30 +01:00
parent 33f50c7278
commit b5525bd3fb
6 changed files with 259 additions and 24 deletions
+7
View File
@@ -1690,6 +1690,8 @@ def shift_add(request, rota_id):
"workers_required": int(data["workers_required"]),
"assign_as_block": bool(data["assign_as_block"]),
"balance_offset": data.get("balance_offset"),
"include_groups": data.get("include_groups", []),
"exclude_groups": data.get("exclude_groups", []),
"constraints": data.get("constraints", []),
}
@@ -1738,6 +1740,9 @@ def shift_edit(request, rota_id, idx):
"days": data["days"],
"workers_required": int(data["workers_required"]),
"assign_as_block": bool(data["assign_as_block"]),
"balance_offset": data.get("balance_offset"),
"include_groups": data.get("include_groups", []),
"exclude_groups": data.get("exclude_groups", []),
"constraints": data.get("constraints", []),
}
current = rota.shifts or []
@@ -1766,6 +1771,8 @@ def shift_edit(request, rota_id, idx):
"workers_required": shift.get("workers_required"),
"assign_as_block": shift.get("assign_as_block", False),
"balance_offset": shift.get("balance_offset", None),
"include_groups": ",".join(shift.get("include_groups") or []),
"exclude_groups": ",".join(shift.get("exclude_groups") or []),
"constraints": json.dumps(shift.get("constraints", [])) if shift.get("constraints") is not None else "",
}
form = ShiftForm(initial=initial)