def update_employee(): form = EmployeeSubmitForm() employee = Employee() _, name, _, _ = request_get(request.args) if request.method == 'POST' and form.validate_on_submit(): request_data = { 'name': form.name.data, 'department': form.department.data, 'rank': form.rank.data } if form.employeeId.data: request_data['employeeId'] = int(form.employeeId.data) if form.beginDate.data: request_data['beginDate'] = form.beginDate.data.strftime( '%Y-%m-%d') if form.endDate.data: request_data['endDate'] = form.endDate.data.strftime('%Y-%m-%d') if form.email.data: request_data['email'] = form.email.data if form.regular.data: request_data['regular'] = form.regular.data if form.status.data: request_data['status'] = form.status.data employee.post(request_data) return redirect(url_for('main.employees')) data = employee.get(name=name) return render_template('user/update_employee.html', **locals())
def edit_record(self, record_id): """Edit Record""" self.clear_screen() record = Employee.get(Employee.id == record_id) if input("Are you sure you would like to update " + record.task_name + " ? ").lower() == "y": print("Name is currently set to: " + record.name) record.name = input("Enter the name: ") print("Title is currently set to: " + record.task_name) record.task_name = input("Enter a title: ") while True: try: print("Time Spent is currently set to: " + str(record.time_spent)) record.time_spent = int(input("Enter time spent: ")) if record.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: print("Notes are currently set to: " + record.notes) record.notes = input("Enter a notes: ") break record.save()
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 employees(): employee = Employee() page, name, _, _ = request_get(request.args) paging, data_list = employee.get(page=page) return render_template('user/employees.html', **locals())
def search_by_name(cls): """Search by Employee Name""" employee = Employee.get(Employee.name == utils.get_search_name()) entries = employee.tasks.join(Employee).order_by( Employee.name, Task.date) return [entry for entry in entries]