Exemple #1
0
def create_university():
    name = request.form.get("name")
    code = request.form.get("code")

    university = University(code=code, name=name)

    university.createUniversity(university)

    return "University created!"
Exemple #2
0
def get_all_universities():
    university = University()

    result = university.getAllUniversities()

    universities = []

    for i in result:
        i["_id"] = str(i["_id"])
        universities.append(i)

    return jsonify(universities)
def admin():
    universities = University().getAllUniversities()
    courses = Course().getAllCourses()
    coordinators = Coordinator().getAllCoordinators()

    return render_template("administrator.html",
                           universities=universities,
                           courses=courses,
                           coordinators=coordinators)
Exemple #4
0
def create_course():
    name = request.form.get("name")
    code = request.form.get("code")
    print(request.form.get("university"))
    university = University().getUniversityByCode(request.form.get("university"))
    coordinator = Coordinator().getCoordinatorByCode(request.form.get("coordinator"))
    createdAt = request.form.get("createdAt")

    course = Course(name=name, code=code, coordinator=coordinator, university=university, createdAt=createdAt)

    if course.createCourse(course):
        return "Course created!", 200
    else:
        return "Error", 400
Exemple #5
0
def create_student():
    name = request.form.get("name")
    email = request.form.get("email")
    code = request.form.get("code")
    password = request.form.get("password")
    createdAt = request.form.get("createdAt")
    university = University().getUniversityByCode(request.form.get("university"))
    course = Course().getCourseByCode(request.form.get("course"))

    user = Student(code=code, name=name, email=email, password=password, createdAt=createdAt, university=university, course=course)

    if user.create(user):
        return redirect("/app/login/")
    else:
        return render_template("signup/signup.html", error="Houve um problema ao tentar cadastrar estudante. Tente novamente.")
def create_teacher():
    name = request.form.get("name")
    email = request.form.get("email")
    code = request.form.get("code")
    password = request.form.get("password")
    createdAt = request.form.get("createdAt")
    university = University().getUniversityByCode(
        request.form.get("university"))
    course = Course().getCourseByCode(request.form.get("course"))

    teacher = Teacher(code=code,
                      name=name,
                      email=email,
                      password=password,
                      createdAt=createdAt,
                      university=university,
                      course=course)

    if teacher.create(teacher):
        return "teacher created!", 200
    else:
        return "Error", 400