def edit_attendance(attendance_id): if request.method == 'POST': studentname = request.form['studentname'] teacherusername = request.form['teacherusername'] date = request.form['date'] time = request.form['time'] lessonname = request.form['lessonname'] attendance = Attendance.get_by_id(attendance_id) attendance.studentname = studentname attendance.teacherusername = teacherusername attendance.date = date attendance.time = time attendance.lessonname = lessonname attendance.save_to_mongo() return redirect(url_for('.index')) else: attendance = Attendance.get_by_id(attendance_id) # teacher = Teacher.get_by_username(attendance.teacherusername) # student = Student.get_by_username(attendance.studentname) # lesson = Lesson.get_by_name(attendance.lesson) return render_template("attendance/edit_attendance.jinja2", attendance=attendance, teachers=Teacher.all(), students=Student.all(), lessons=Lesson.all(), teacherusername=attendance.teacherusername, student=attendance.studentname, curlessonname=attendance.lessonname)
def edit_lesson(lesson_id): if request.method == 'POST': name = request.form['name'] teacherusername = request.form['teacherusername'] date = request.form['date'] time = request.form['time'] lessontype = request.form['lessontype'] lesson = Lesson.get_by_id(lesson_id) lesson.name = name lesson.teacherusername = teacherusername lesson.date = date lesson.time = time lesson.lessontype = lessontype lesson.save_to_mongo() return redirect(url_for('.index')) else: lesson = Lesson.get_by_id(lesson_id) teachers = Teacher.all() attendances = Attendance.get_by_lessonname(lesson.name) return render_template("lessons/edit_lesson.jinja2", lesson=lesson, teacherusername=lesson.teacherusername, teachers=teachers, types=Lesson.get_lesson_types(), curlessontype=lesson.lessontype, attendances=attendances)
def create_lesson(): if request.method == 'POST': name = request.form['name'] teacherusername = request.form['teacher'] date = request.form['date'] time = request.form['time'] lessontype = request.form['lessontype'] Lesson(name, teacherusername, date, time, lessontype).save_to_mongo() return redirect(url_for('.index')) return render_template("lessons/new_lesson.jinja2", teachers=Teacher.all(), types=Lesson.get_lesson_types())
def create_teacher(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] firstname = request.form['firstname'] lastname = request.form['lastname'] location = request.form['location'] active = request.form['active'] try: Teacher.check_before_save(username, password, firstname, lastname, location, active) except TeacherErrrors.TeacherWrongInputDataException as e: return e.message except TeacherErrrors.TeacherExistsException as e: return e.message Teacher(username, password, firstname, lastname, location, active).save_to_mongo() return redirect(url_for(".index")) return render_template("teachers/new_teacher.jinja2")
def edit_teacher(teacher_id): if request.method == 'POST': username = request.form['username'] password = request.form['password'] firstname = request.form['firstname'] lastname = request.form['lastname'] location = request.form['location'] active = request.form['active'] teacher = Teacher.get_by_id(teacher_id) teacher.username = username teacher.password = password teacher.firstname = firstname teacher.lastname = lastname teacher.location = location teacher.active = active teacher.save_to_mongo() return redirect(url_for('.index')) return render_template("teachers/edit_teacher.jinja2", teacher=Teacher.get_by_id(teacher_id))
def create_attendance(): if request.method == 'POST': studentname = request.form['studentname'] teacherusername = request.form['teacherusername'] date = request.form['date'] time = request.form['time'] lessonname = request.form['lessonname'] Attendance(studentname, teacherusername, date, time, lessonname).save_to_mongo() return redirect(url_for('.index')) else: teachers = Teacher.all() students = Student.all() lessons = Lesson.all() return render_template("attendance/new_attendance.jinja2", teachers=teachers, students=students, lessons=lessons)
def teacher_page(teacher_username): teacher = Teacher.get_by_username(teacher_username) if teacher is not None: return render_template('teachers/teacher.jinja2', teacher=teacher) else: return "wrong user name"
def delete_teacher(teacher_id): Teacher.get_by_id(teacher_id).delete() return redirect(url_for('.index'))
def index(): teachers = Teacher.all() return render_template('teachers/teacher_index.jinja2', teachers=teachers)