def admin_add_course(): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: handle_add_course(request.form) return redirect(host + "/admin/courses")
def admin_drop_course(course_id): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: course_management_api.delete_course(course_id) return redirect(host + "/admin/courses")
def drop_student(user_type, student_id): user_name, _ = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") _type = "X" if user_type == "student": _type = USER.STUDENT else: return redirect(host + "/logout") user_manager_api.delete_user(student_id, _type) return redirect(host + "/admin/" + user_type)
def handle_section_action(course_id, sec_no, action): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") elif action == "add_professor": team_id = course_management_api.get_team_id(course_id, sec_no) course_management_api.add_professor_to_teaching_team( request.form["email"], team_id) elif action == "drop_professor": team_id = course_management_api.get_team_id(course_id, sec_no) course_management_api.drop_professor_from_teaching_team( request.form["email"], team_id) elif action == "add_student": course_management_api.add_student_section(request.form["email"], course_id, sec_no) elif action == "drop_student": course_management_api.drop_student_section(request.form["email"], course_id, sec_no) return redirect("/".join([host, "admin/courses", course_id, sec_no]))
def render_admin_home(): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: return make_response(render_template("admin/home.html"))
def render_admin_section(course_id, sec_no): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: return render_admin_single_section(course_id, sec_no)
def render_admin_courses(): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: return render_admin_courses_page()
def add_section(course_id): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") handle_add_section(course_id, request.form) return redirect("/".join([host, "admin/courses", course_id]))