def delete_salary(request): if not has_admin_access(request): return HttpResponseRedirect(reverse('guest')) employee = EmployeeIdentifier() if request.method == 'POST': employee = EmployeeIdentifier(request.POST) if employee.is_valid(): cleaned_data = employee.cleaned_data if cleaned_data.get('id'): target_employee = Employee.find_employee_all_info_by_id( cleaned_data.get('id')) if target_employee: return render(request, 'delete/salary_employee.html', {'employee': target_employee}) if cleaned_data.get('first_name') and cleaned_data.get( 'last_name'): target_employee = Employee.find_employee_by_name( cleaned_data.get('first_name'), cleaned_data.get('last_name')) target_employee = Employee.find_employee_all_info_by_id( target_employee['employee_id']) if target_employee: return render(request, 'delete/salary_employee.html', {'employee': target_employee}) messages.error(request, "No such employee.") return render(request, 'delete/before_search.html', {'employee': employee})
def find_employee_all_info_by_name(first_name, last_name): employee = Employee.find_employee_by_name(first_name, last_name) if employee: result = Employee.find_employee_all_info_by_id(employee['employee_id']) else: return None return result
def read_employee(request): forms = EmployeeIdentifier() if request.method == 'POST': forms = EmployeeIdentifier(request.POST) if forms.is_valid(): cleaned_data = forms.cleaned_data result = None if cleaned_data.get('id'): e_id = cleaned_data.get('id') result = Employee.find_employee_all_info_by_id(e_id) if result: return render(request, 'read/show_employee_result.html', {'employee': result}) if cleaned_data.get('first_name') and cleaned_data.get( 'last_name'): first_name = cleaned_data.get('first_name') last_name = cleaned_data.get('last_name') result = find_employee_all_info_by_name(first_name, last_name) return render(request, 'read/show_employee_result.html', {'employee': result}) return render(request, 'read/read_employee.html', {'forms': forms})
def read_employee_info(request, employee_id): employee = Employee.find_employee_all_info_by_id(employee_id) return render(request, 'read/show_employee_result.html', {'employee': employee})