rename home to remote

This commit is contained in:
Ross
2022-02-24 21:50:37 +00:00
parent 7807e3b1e8
commit 9e873ac5f7
11 changed files with 806 additions and 145 deletions
+23 -10
View File
@@ -1,26 +1,33 @@
import datetime
from collections import defaultdict
from typing import List
# from shifts import RotaBuilder, days, sites
#from .shifts import RotaBuilder, days, sites
import uuid
#from rota.shifts import RotaBuilder
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from rota.shifts import RotaBuilder
class Worker:
def __init__(
self,
Rota, # Aim to remove (workers should be independent of rotas)
Rota: "RotaBuilder", # Aim to remove (workers should be independent of rotas)
name: str,
site: str,
grade: int,
id=None,
fte: int = 100,
nwd=None,
end_date=None,
nwd: list[str] | list[str, datetime.datetime, datetime.datetime]=[],
end_date: datetime.datetime | None =None,
oop=None,
not_available_to_work=None,
pref_not_to_work=None,
work_requests=None,
home_site: str = "plymouth", # We set a default proc_site
remote_site: str = "plymouth", # We set a default proc_site
previous_shifts: dict = {},
shift_balance_extra: dict = {},
bank_holiday_extra: int = 0,
@@ -38,14 +45,14 @@ class Worker:
# rules is easier.
self.grade = grade
self.fte = fte
self.nwd = nwd
self.nwd = []
self.proportion_rota_to_work = 1
self.pair = pair
self.shift_balance_extra = shift_balance_extra
self.bank_holiday_extra = bank_holiday_extra
self.home_site = home_site
if home_site == "plymouth" or home_site == "":
self.remote_site = remote_site
if remote_site == "plymouth" or remote_site == "":
self.night_at_derriford = 1
else:
self.night_at_derriford = 0
@@ -155,7 +162,13 @@ class Worker:
if self.fte_adj > 100:
raise ValueError("{} : fte_ajd = {}".format(self.name, self.fte_adj))
# print(self.name, self.nwd)
assert type(nwd) == list, f"nwd must be a list: {nwd=}"
for item in nwd:
match item:
case (nwd_day, start_date, end_date):
self.nwd.append((nwd_day, start_date, end_date))
case nwd_day:
self.nwd.append((nwd_day, Rota.start_date, Rota.rota_end_date))
def __lt__(self, other) -> bool:
return (self.site, self.grade, self.fte_adj, self.name) < (
@@ -172,7 +185,7 @@ class Worker:
self.name,
(self.site, self.grade, self.fte_adj),
nwd,
self.home_site,
self.remote_site,
self.night_at_derriford,
)