This commit is contained in:
Ross
2021-01-17 10:07:02 +00:00
parent c2cee02158
commit 68738a2cfe
+18 -11
View File
@@ -50,6 +50,9 @@ class Worker:
else:
days_to_work = (self.end_date - Rota.start_date).days
if days_to_work < 0:
days_to_work = 0
# add unavalabilities
for weeks_days in Rota.weeks_days_product[days_to_work:]:
week, day = weeks_days
@@ -62,21 +65,25 @@ class Worker:
end_oop_date = datetime.datetime.strptime(end_oop,
"%Y/%m/%d").date()
if end_oop_date > Rota.rota_end_date:
end_oop_date = Rota.rota_end_date
# ignore oops if they finish before the rota start date
if end_oop_date < Rota.start_date:
if end_oop_date > Rota.rota_end_date:
end_oop_date = Rota.rota_end_date
if start_oop_date < Rota.start_date:
start_oop_date = Rota.start_date
if start_oop_date < Rota.start_date:
start_oop_date = Rota.start_date
oop_length = (end_oop_date - start_oop_date).days
days_to_work = days_to_work - oop_length
days_until_oop = (start_oop_date - Rota.start_date).days
oop_length = (end_oop_date - start_oop_date).days
days_to_work = days_to_work - oop_length
for weeks_days in Rota.weeks_days_product[
days_until_oop:days_until_oop + oop_length]:
week, day = weeks_days
Rota.unavailable_to_work.add((self.id, week, day))
days_until_oop = (start_oop_date - Rota.start_date).days
for weeks_days in Rota.weeks_days_product[
days_until_oop:days_until_oop + oop_length]:
week, day = weeks_days
Rota.unavailable_to_work.add((self.id, week, day))
if pref_not_to_work is not None:
# loop throught dates converting to week / day combination