def ask_employee(self, inputtxt=None): """Ask the title for the task""" while_breaker = 1 while True: # This helps the testing, since these are kind of # infinite loops while testing, there's need for something # that can break them automatically if while_breaker > 100: break else: while_breaker += 1 utils.cls() name = utils.get_input(inputtxt) if not name: utils.pause('Error: Blanks spaces are not allowed') continue try: employee = Employee.get(Employee.name == name) except Employee.DoesNotExist: employee = Employee.create(name=name) return employee.id_employee
def mutate(self, info, input): ok = False if ('department_id' in input): input['department_id'] = utils.global_id_to_db_id( input['department_id']) employee = EmployeeModel.create(input) ok = True return CreateEmployee(employee=employee, ok=ok)
def make_emp(line, cp): flds = line.split('^') if Employee.has_payrecord(flds[1]): return Employee.get_by_name(flds[1]) return Employee.create( dfn=flds[0], name=flds[1], grade=int(flds[2]), step=int(flds[3]), fte=int(float(flds[4]) * 100), cp=cp )
def add_entry(self): """Add a new record""" self.clear_screen() employee_name = input("Enter the name: ") task_title = input("Enter a title: ") while True: try: task_time_spent = int(input("Enter time spent: ")) if task_time_spent < 0: print("Sorry, your response must not be negative.") continue except ValueError: print("Your selection is not a number, please try again: ") continue else: task_notes = input("Enter a notes: ") break Employee.create(name=employee_name, task_name=task_title, time_spent=task_time_spent, notes=task_notes)
def setUp(self): self.employee = Employee.create( name = 'TestEmployee' )