Example #1
0
 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
Example #2
0
 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
Example #3
0
 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
Example #4
0
 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
Example #5
0
 def pick_up_admin(cls, employee: Employee):
     employee.is_admin = False
     return employee
Example #6
0
 def grant_to_admin(cls, employee: Employee):
     employee.is_admin = True
     return employee
Example #7
0
 def set_balance_vac(cls, employee: Employee, balance_vac):
     employee.vacation = balance_vac
     return employee
Example #8
0
 def deactivate(cls, employee: Employee):
     employee.activated = False
     return employee
Example #9
0
 def activate(cls, employee: Employee):
     employee.activated = True
     return employee