示例#1
0
def delete_assistant(employee_id):
    """
    Remove assistant from list(data base)
    :param employee_id: int
    GET return list of assistants without removed assistant
    """
    assistant = Employee.get_by_id(employee_id, 'assistant')
    assistant.delete_employee()
    flash('Assistant was deleted')
    return redirect(url_for('employee_controller.list_assistants'))
示例#2
0
def edit_assistant(employee_id):
    """
    Edit assistant formula to edit assistant details
    :param employee_id: int
    GET return edit assistants formula
    POST return list of assistants with edited assistant changes saved
    """
    assistant = Employee.get_by_id(employee_id, 'assistant')
    if request.method == 'POST':
        save_employee('assistant', 'edit', assistant)
        flash('Assistant was edited')
        return redirect(url_for('employee_controller.list_assistants'))
    return render_template('editemployee.html', user=user_session(session['user'], session['type']), employee=assistant,
                           list='employee_controller.list_assistants')
def user_session(id, class_name):
    """Return object with given class name in class_name and id"""
    if class_name == "Student":

        return Student.get_by_id(id)
    elif class_name == "Mentor":

        return Mentor.get_by_id(id)
    elif class_name == "Employee":

        return Employee.get_by_id(id, 'assistant')
    elif class_name == "Manager":

        return Manager.get_by_id(id)
    return None