Update calculating rotation index for updated shift, fix schedule preview with respect to rotation index

This commit is contained in:
Julia 2022-09-07 19:02:24 +03:00
parent 9f71b5d72f
commit e029464fa2
2 changed files with 6 additions and 1 deletions

View file

@ -561,7 +561,11 @@ class CustomOnCallShift(models.Model):
instance_data["rotation_start"].date(),
instance_data["start"].time(),
).astimezone(pytz.UTC)
instance_data["start_rotation_from_user_index"] = self.get_rotation_user_index()
# calculate rotation index to keep user rotation order
start_rotation_from_user_index = self.get_rotation_user_index() + self.start_rotation_from_user_index
if start_rotation_from_user_index >= len(instance_data["rolling_users"]):
start_rotation_from_user_index = 0
instance_data["start_rotation_from_user_index"] = start_rotation_from_user_index
if self.last_updated_shift is None or self.last_updated_shift.event_is_started:
# create new shift

View file

@ -676,6 +676,7 @@ class OnCallScheduleWeb(OnCallSchedule):
pass
else:
if update_shift.event_is_started:
custom_shift.start_rotation_from_user_index = update_shift.start_rotation_from_user_index
update_shift.until = custom_shift.rotation_start
extra_shifts.append(update_shift)
else: