def register(cls, employee: Employee, employment_date: datetime, balance_vac=0): employee.acceptance_date = datetime.now() employee.employment_date = employment_date employee.activated = True employee.vacation = balance_vac return employee
def update_with(cls, employee: Employee, name=None, password=None, email=None, employment_date: datetime = None): employee.employment_date = employment_date if employment_date else employee.employment_date employee.password = password if password else employee.password employee.email = email if email else employee.email employee.name = name if name else employee.name return employee
def deserialize(cls, serialized_employee: dict): employee = Employee() for key, value in serialized_employee.items(): if 'date' in key and value: value = datetime.strptime(value, '%Y.%m.%d') setattr(employee, key, value) return employee
def create_simple(cls, name, password, email): employee = Employee() employee.name = name employee.email = email employee.password = password employee.activated = False employee.is_admin = False return employee
def pick_up_admin(cls, employee: Employee): employee.is_admin = False return employee
def grant_to_admin(cls, employee: Employee): employee.is_admin = True return employee
def set_balance_vac(cls, employee: Employee, balance_vac): employee.vacation = balance_vac return employee
def deactivate(cls, employee: Employee): employee.activated = False return employee
def activate(cls, employee: Employee): employee.activated = True return employee