コード例 #1
0
ファイル: app.py プロジェクト: gitsubmit/gitsubmit-backend
def add_student(class_url):
    """ covered by test 0_classes / `Student can enroll in a class` """
    json_data = get_json_data()
    student = json_data.get("username")
    dbw = DatabaseWrapper(GITOLITE_ADMIN_PATH, DATABASE_PORT)
    try:
        dbw.add_student_to_class(class_url, student)
    except ClassDoesNotExistError as e:
        return jsonify({"error": "class not found!", "exception": str(e)}), 404
    except UserDoesNotExistError as e:
        return jsonify({"error": "username not found!", "exception": str(e)}), 404

    return jsonify(class_updated=dbw.get_class_or_error(class_url))
コード例 #2
0
    # populate the databases with some data
    dbw.create_user("student1", "*****@*****.**", password, "Student", "One")
    dbw.create_user("student2", "*****@*****.**", password, "Student", "Two")
    dbw.create_user("teacher1", "*****@*****.**", password, "Teacher", "One")
    dbw.create_user("teacher2", "*****@*****.**", password, "Teacher", "Two")
    dbw.create_user("teacher_usable", "*****@*****.**", password, "Teacher", "Usable")
    dbw.create_user("student_usable", "*****@*****.**", password, "Student", "Usable")
    dbw.create_user("spencer", "*****@*****.**", password, "Spencer", "Hawkins")  # because of some hardcoded stuff, heh
    dbw.create_user("konrad", "*****@*****.**", password, "Konrad", "Ryce")  # because of some hardcoded stuff, heh

    dbw.create_class("intro_to_computers", "Introduction to Computers", "Introduction to Computers description", "teacher1")
    dbw.create_class("adv_computers", "Advanced Computers", "Advanced Computers description", "teacher2")
    dbw.create_class("test_class", "a test class usable for actual git tests", "description", "teacher_usable")

    dbw.add_student_to_class("intro_to_computers", "student1")
    dbw.add_student_to_class("adv_computers", "student2")
    dbw.add_student_to_class("test_class", "student_usable")

    dbw.create_project("turn_on_a_computer", "Turn on a computer", "Turn on a computer description",
                       "intro_to_computers", False, (datetime.datetime.now() + datetime.timedelta(days=5)).strftime("%Y-%m-%d"), "teacher1")

    dbw.create_project("use_a_computer", "Use a computer", "Use a computer description",
                       "adv_computers", False, (datetime.datetime.now() + datetime.timedelta(days=2)).strftime("%Y-%m-%d"), "teacher2")

    dbw.create_project("test_project", "a test project", "description",
                       "test_class", False, (datetime.datetime.now() + datetime.timedelta(days=2)).strftime("%Y-%m-%d"), "teacher_usable")

    dbw.ssh_host = args.ssh_host
    dbw.create_submission("turned_on_a_computer", "Student 1 turned on a computer", "intro_to_computers/turn_on_a_computer", "student1")
    dbw.create_submission("used_a_computer", "Student 2 used a computer", "adv_computers/use_a_computer", "student2")