def register(): if request.method == 'GET': return render_template("module_1/register.html") else: name = request.form.get("name") course = request.form.get("course") teacher = Teacher(name, course) session["teacher"] = serialize(teacher) return redirect(url_for(".index"))
def add(): if request.method == "GET": return render_template("module_1/add.html") else: id = request.form.get("id") firstname = request.form.get("firstname") lastname = request.form.get("lastname") gender = request.form.get("gender") teacher = retrieve_teacher() teacher.students[id] = Student(id, firstname, lastname, gender) session['teacher'] = serialize(teacher) return redirect(url_for(".show_students"))
def edit(id): teacher = retrieve_teacher() student = teacher.students.pop(id) if request.method == "GET": return render_template("module_1/edit.html", student=student) else: student.first_name = request.form.get("firstname") student.last_name = request.form.get("lastname") student.gender = request.form.get("gender") teacher.students[id] = student session["teacher"] = serialize(teacher) return redirect(url_for(".show_students"))
def delete(id): teacher = retrieve_teacher() teacher.students.pop(id) session["teacher"] = serialize(teacher) return redirect(url_for(".show_students"))