Beispiel #1
0
def update_teacher():
    courses = [course for course in request.form["teacher-courses"].split(',')]
    if Courses.check_courses(database=Database.db, courses=courses):
        Message.course_found_success()
    else:
        Message.course_found_fail()
    temp = Teacher.update_teacher(database=Database.db,
                                  prof_id=request.form["prof-id"],
                                  name=request.form["teacher-name"],
                                  phone_no=request.form["teacher-phone-no"],
                                  address=request.form["teacher-address"],
                                  courses=courses)
    if temp.matched_count == 1:
        Message.update_teacher_record_success()
    else:
        Message.update_teacher_record_fail()
    return redirect("/")
Beispiel #2
0
def add_teacher():
    teacher = Teacher(db=Database.db,
                      prof_id=request.form["prof-id"],
                      name=request.form["teacher-name"],
                      phone_no=request.form["teacher-phone-no"],
                      address=request.form["teacher-address"],
                      password=request.form["teacher-password"],
                      courses=request.form["teacher-courses"])
    if teacher.is_success and teacher.is_course:
        Message.add_teacher_record_success()
        Message.course_found_success()
        teacher.save_to_mongo(database=Database.db)
    elif not teacher.is_course and teacher.is_success:
        Message.course_found_fail()
    elif not teacher.is_success and teacher.is_course:
        Message.add_teacher_record_fail()
    elif not teacher.is_success and not teacher.is_course:
        Message.add_teacher_record_fail()
        Message.course_found_fail()
    return redirect("/")