コード例 #1
0
ファイル: app.py プロジェクト: gitsubmit/gitsubmit-backend
def new_project(class_url):
    """ covered by test 2_projects / `Teacher can create new project` """
    json_data = get_json_data()
    project_name = json_data.get("project_name")
    url_name = json_data.get("url_name")
    description = json_data.get("description")
    team_based = json_data.get("team_based") in ["True", "true", "Yes", "yes"]
    max_size = int(json_data.get("max_members"))
    due_date = json_data.get("due_date")  # TODO: check formatting from js

    owner = get_current_logged_in_user()
    if owner is None:
        owner = "spencer"  # TODO: instead raise here

    dbw = DatabaseWrapper(GITOLITE_ADMIN_PATH, DATABASE_PORT)
    try:
        dbw.create_project(url_name, project_name, description, class_url, team_based, due_date, owner, max_size)
        return jsonify(project_created=url_name)
    except UrlNameAlreadyTakenError as e:
        return jsonify({"error": "Url name was already taken!", "exception": str(e)}), 403
    except ClassDoesNotExistError as e:
        return jsonify({"error": "Class does not exist!", "exception": str(e)}), 404
コード例 #2
0
    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")
    dbw.create_submission("test_submission", "a test submission", "test_class/test_project", "student_usable")