.
This commit is contained in:
+18
-11
@@ -50,6 +50,9 @@ class Worker:
|
|||||||
else:
|
else:
|
||||||
days_to_work = (self.end_date - Rota.start_date).days
|
days_to_work = (self.end_date - Rota.start_date).days
|
||||||
|
|
||||||
|
if days_to_work < 0:
|
||||||
|
days_to_work = 0
|
||||||
|
|
||||||
# add unavalabilities
|
# add unavalabilities
|
||||||
for weeks_days in Rota.weeks_days_product[days_to_work:]:
|
for weeks_days in Rota.weeks_days_product[days_to_work:]:
|
||||||
week, day = weeks_days
|
week, day = weeks_days
|
||||||
@@ -62,21 +65,25 @@ class Worker:
|
|||||||
end_oop_date = datetime.datetime.strptime(end_oop,
|
end_oop_date = datetime.datetime.strptime(end_oop,
|
||||||
"%Y/%m/%d").date()
|
"%Y/%m/%d").date()
|
||||||
|
|
||||||
if end_oop_date > Rota.rota_end_date:
|
|
||||||
end_oop_date = Rota.rota_end_date
|
|
||||||
|
|
||||||
if start_oop_date < Rota.start_date:
|
# ignore oops if they finish before the rota start date
|
||||||
start_oop_date = 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
|
||||||
|
|
||||||
oop_length = (end_oop_date - start_oop_date).days
|
if start_oop_date < Rota.start_date:
|
||||||
days_to_work = days_to_work - oop_length
|
start_oop_date = Rota.start_date
|
||||||
|
|
||||||
days_until_oop = (start_oop_date - Rota.start_date).days
|
|
||||||
|
|
||||||
for weeks_days in Rota.weeks_days_product[
|
oop_length = (end_oop_date - start_oop_date).days
|
||||||
days_until_oop:days_until_oop + oop_length]:
|
days_to_work = days_to_work - 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:
|
if pref_not_to_work is not None:
|
||||||
# loop throught dates converting to week / day combination
|
# loop throught dates converting to week / day combination
|
||||||
|
|||||||
Reference in New Issue
Block a user