Merge branch 'master' of git.xkjq.uk:ross/proc-rota

This commit is contained in:
Ross
2025-12-19 22:06:00 +00:00
2 changed files with 15 additions and 12 deletions
+10 -10
View File
@@ -293,6 +293,7 @@ class RequireRemoteSitePresenceConstraint(BaseShiftConstraint):
class MaxShiftsPerWeekConstraint(BaseShiftConstraint):
max_shifts: int | None = None
days: Optional[List[str]] = None
class MaxShiftsPerWeekBlockConstraint(BaseShiftConstraint):
week_block : int
@@ -3007,20 +3008,19 @@ class RotaBuilder(object):
shift_number = constraint.max_shifts
else:
shift_number = constraint_shift.get_shift_number()
try:
# If the constraint specifies particular days, only count those days,
# otherwise count the shift's own days.
constraint_days = (
constraint.days if constraint.days is not None else self.days
)
self.model.constraints.add(
shift_number
>= sum(
self.model.works[
worker.id, w, day, constraint_shift.name
]
# for shiftname in self.get_shift_names_by_week_day(week, day)
# for day in self.days
for w, day in self.get_week_day_combinations_for_shift(
constraint_shift
)
if w == week
self.model.works[worker.id, w, day, constraint_shift.name]
for w, day in self.get_week_day_combinations_for_shift(constraint_shift)
if w == week and day in constraint_days
)
)
except ValueError: