Пример #1
0
def add_session(student_id):
    form = AddStudentSessionForm()
    student = get_student_by_id(student_id)
    if form.validate_on_submit():
        date = form.date.data
        duration = form.duration.data
        session_type = form.session_type.data
        project = form.project.data
        summary = form.summary.data
        progress = form.progress.data
        concerns = form.concerns.data
        personal_notes = form.personal_notes.data

        student_session = create_student_session(
            student_id,
            date,
            duration,
            session_type,
            project,
            summary,
            progress,
            concerns,
            personal_notes,
        )

        if form.send_feedback.data == "yes":
            session["feedback_url"] = generate_feedback_url(
                student, student_session, current_user)

        flash("Session successfully saved", "success")
        return redirect(url_for("students.view", student_id=student.id))

    return render_template("students/sessions/create.html",
                           student=student,
                           form=form)
Пример #2
0
def update_session(student_id, session_id):
    form = AddStudentSessionForm()
    student = get_student_by_id(student_id)
    session = get_session_by_id(session_id)
    if form.validate_on_submit():
        date = form.date.data
        duration = form.duration.data
        session_type = form.session_type.data
        project = form.project.data
        summary = form.summary.data
        progress = form.progress.data
        concerns = form.concerns.data
        personal_notes = form.personal_notes.data

        update_student_session(
            student_id,
            session_id,
            date,
            duration,
            session_type,
            project,
            summary,
            progress,
            concerns,
            personal_notes,
        )

        flash("Session successfully updated", "success")
        return redirect(url_for("students.view", student_id=student_id))

    return render_template("students/sessions/edit.html",
                           student=student,
                           form=form,
                           session=session)
Пример #3
0
def view(student_id):
    student = get_student_by_id(student_id)
    add_student_note_form = AddStudentNoteForm()

    if not student:
        return abort(404)

    if current_user.id is not student.mentor_id:
        return abort(404)

    return render_template(
        "students/view.html",
        student=student,
        add_student_note_form=add_student_note_form,
    )
Пример #4
0
def edit(student_id):
    form = EditStudentForm()
    student = get_student_by_id(student_id)
    if form.validate_on_submit():
        name = form.name.data
        email = form.email.data
        course = form.course.data
        stage = form.stage.data
        active = True if form.active.data == "1" else False

        if not update_student(student.id, name, email, course, stage, active,
                              current_user.id):
            return redirect(url_for("students.index")), 403

        flash("Student Successfully Updated")
        return redirect(url_for("students.index"))

    return render_template("students/edit.html", form=form, student=student)
Пример #5
0
def add_note(student_id):
    form = AddStudentNoteForm()
    student = get_student_by_id(student_id)
    if form.validate_on_submit():
        note = form.note.data

        add_student_note(student.id, note)

        if form.update_contact_date.data == "yes":
            update_contact_date(student_id)

        flash("Note successfully saved", "success")
        return redirect(url_for("students.view", student_id=student.id))

    flash(
        "There was a problem adding this note, make sure you actually add a note",
        "error",
    )
    return render_template("students/view.html",
                           student=student,
                           add_student_note_form=form)