def employeeSignUp(): questions = [ inquirer.Text('name', message="What's your Name"), inquirer.Text('username', message="What's your username"), inquirer.Text('password', message="What's your password"), inquirer.Text('phone_no', message="What's your Phone #") ] answers = inquirer.prompt(questions) employeeName = answers['name'] employeeUsername = answers['username'] employeePassword = answers['password'] employeePhone_no = answers['phone_no'] employeeStart = "2020-04-27" employeeJob = "Sales Associate" question1 = [inquirer.List( 'employeeLocation', message="Which location do you work at?", choices=['San Jose', 'Alameda', 'Fresno', 'Napa', 'Oakland', 'Monterey', 'Santa Clara'], ),] answer1 = inquirer.prompt(question1) switch={ 'San Jose': 1, 'Alameda': 2, 'Fresno': 3, 'Napa': 4, 'Oakland': 5, 'Monterey': 6, 'Santa Clara': 7 } employeeInfo = switch.get(answer1["employeeLocation"], 1) employeeStoreID = employeeInfo employeeManager = employeeInfo # insert_employee(store_id, supervisor_id) nursery.insert_employee(employeeName, employeeUsername, employeePassword,employeeStoreID, employeeStart, employeePhone_no, employeeJob, employeeManager) print("You have signed up! go ahead and sign in now!") employeeSignIn()
def test1(): #insert into the DB employeeName = "Karanbir Bains" employeeUsername = "******" employeePassword = '******' employeePhone_no = '4085556783' employeeStart = "2020-04-27" employeeJob = "Sales Associate" #Store 1 is San Jose location employeeStoreID = 1 #empId 1 is Lebron James manager fromt the start up script and already in the employeeManager = 1 #do the insert here nursery.insert_employee(employeeName, employeeUsername, employeePassword, employeeStoreID, employeeStart, employeePhone_no, employeeJob, employeeManager) employee = nursery.getEmployeeByName(employeeUsername, "emp_name") if employee == employeeName: print("Test 1 Passed!") else: print("Test 2 Failed!")
def test2(): #insert into the DB employeeName = "Karanbir Bains" employeeUsername = "******" employeePassword = '******' employeePhone_no = '4085556783' employeeStart = "2020-04-27" employeeJob = "Sales Associate" #Store 1 is San Jose location employeeStoreID = 1 #empId 1 is Lebron James manager fromt the start up script and already in the employeeManager = 1 #do the insert here try: nursery.insert_employee(employeeName, employeeUsername, employeePassword, employeeStoreID, employeeStart, employeePhone_no, employeeJob, employeeManager) print("Test 2 Failed!") except Exception as e: # Error should occur here, no duplicates in the DB!!!! print("Test 2 Passed!")
def hireEmployee(empID, storeID): # enter new hire information while True: questions = [inquirer.Text('name', message="Enter employee name")] empName = inquirer.prompt(questions)['name'] flag = False if not empName: msg = '\n[No entry for name]\n' flag = True elif re.search("[0-9]", empName): flag = True msg = '\n[Name cannot contain numbers]\n' if flag: print(msg) questions = [ inquirer.List('select option', message="Choose", choices=['Re-enter', 'Cancel']) ] answer = inquirer.prompt(questions)['select option'] if answer == 'Re-enter': continue else: empManMenu(empID, storeID) else: break while True: questions = [ inquirer.Text('username', message="Enter employee username") ] empUserName = inquirer.prompt(questions)['username'] flag = False if not empUserName: msg = '\n[No entry for username]\n' flag = True if flag: print(msg) questions = [ inquirer.List('select option', message="Choose", choices=['Re-enter', 'Cancel']) ] answer = inquirer.prompt(questions)['select option'] if answer == 'Re-enter': continue else: empManMenu(empID, storeID) else: break while True: questions = [ inquirer.Text('password', message="Enter employee password") ] empPassword = inquirer.prompt(questions)['password'] flag = False if not empPassword: msg = '\n[No entry for password]\n' flag = True if flag: print(msg) questions = [ inquirer.List('select option', message="Choose", choices=['Re-enter', 'Cancel']) ] answer = inquirer.prompt(questions)['select option'] if answer == 'Re-enter': continue else: empManMenu(empID, storeID) else: break while True: questions = [ inquirer.Text('phone_no', message="Enter employee phone number") ] empPhone = inquirer.prompt(questions)['phone_no'] flag = False if not empPhone: msg = '\n[No entry for phone number]\n' flag = True elif re.search('[a-zA-Z]', empPhone): msg = '\n[Phone number contains a letter]\n' flag = True if flag: print(msg) questions = [ inquirer.List('select option', message="Choose", choices=['Re-enter', 'Cancel']) ] answer = inquirer.prompt(questions)['select option'] if answer == 'Re-enter': continue else: empManMenu(empID, storeID) else: break while True: questions = [ inquirer.Text('start_date', message="Enter employee start date (yyyy-mm-dd)") ] empStartDate = inquirer.prompt(questions)['start_date'] flag = False if not empStartDate: msg = '\n[No entry for start date]\n' flag = True elif not re.search('\d{4}[-\.\s]\d{1,2}[-\.\s]\d{1,2}', empStartDate): msg = '\n[Date format invalid]\n' flag = True else: empStartDate = re.sub(r'[\.\s]', '-', empStartDate) if not valiDate(empStartDate): msg = '\n[Date invalid]\n' flag = True if flag: print(msg) questions = [ inquirer.List('select option', message="Choose", choices=['Re-enter', 'Cancel']) ] answer = inquirer.prompt(questions)['select option'] if answer == 'Re-enter': continue else: empManMenu(empID, storeID) else: break questions = [ inquirer.List('job_title', message='Select employee job title', choices=['Manager', 'Sales Associate'], default='Sales Associate') ] empJobTitle = inquirer.prompt(questions)['job_title'] empMngrID = empID if not 'Manager' == empJobTitle else None empStoreID = storeID nursery.insert_employee(empName, empUserName, empPassword, empStoreID, empStartDate, empPhone, empJobTitle, empMngrID) print('\n[Employee successfully entered]\n') empManMenu(empID, storeID)