Example #1
0
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")
Example #2
0
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")
Example #3
0
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)
Example #4
0
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]))
Example #5
0
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"))
Example #6
0
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)
Example #7
0
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()
Example #8
0
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]))