Ejemplo n.º 1
0
def add_student():
    form = StudentValidForm()

    if request.method == 'GET':
        return render_template('student/add_student.html',
                               form=form,
                               form_name="add student form")
    else:
        if form.validate():
            new_student = ormStudent(
                student_recordbook=form.student_recordbook.data,
                student_name=form.student_name.data,
                student_surname=form.student_surname.data,
                student_groupe=form.student_groupe.data,
                student_faculty=form.student_faculty.data)

            try:
                session.add(new_student)
                session.commit()
                return redirect('/student')
            except:
                form.student_recordbook.errors = [
                    'Student with this record book already exists!'
                ]
                return render_template('student/add_student.html',
                                       form=form,
                                       form_name="add student form")

        else:
            return render_template('student/add_student.html',
                                   form=form,
                                   form_name="add student form")
Ejemplo n.º 2
0
def add_student():
    form = StudentValidForm()

    if request.method == 'GET':
        return render_template('student/add_student.html',
                               form=form,
                               form_name="add student form")
    else:
        if form.validate():
            new_student = ormStudent(
                student_recordbook=form.student_recordbook.data,
                student_name=form.student_name.data,
                student_surname=form.student_surname.data,
                student_is_worker="true",
                student_time_work=form.student_time_work.data,
                requirement_name='use html5')

            try:
                db.session.add(new_student)
                db.session.commit()
                return redirect('/student')
            except:
                form.student_recordbook.errors = [
                    'Student with this record book already exists!'
                ]
                return render_template('student/add_student.html',
                                       form=form,
                                       form_name="add student form")

        else:
            return render_template('student/add_student.html',
                                   form=form,
                                   form_name="add student form")
Ejemplo n.º 3
0
def edit_student(current_student):
    student = session.query(ormStudent).filter(
        ormStudent.student_recordbook == current_student).one()
    form = StudentValidForm()

    if request.method == 'GET':

        form.student_recordbook.data = student.student_recordbook
        form.student_name.data = student.student_name
        form.student_surname.data = student.student_surname
        form.student_groupe.data = student.student_groupe
        form.student_faculty.data = student.student_faculty

        return render_template('student/student_edit_page.html',
                               form=form,
                               form_name="Edit student")

    else:

        if form.validate():
            student.student_recordbook = form.student_recordbook.data
            student.student_name = form.student_name.data
            student.student_surname = form.student_surname.data
            student.student_groupe = form.student_groupe.data
            student.student_faculty = form.student_faculty.data

            try:
                session.commit()
                return redirect('/student')
            except:
                form.student_recordbook.errors = [
                    'Student with this record book already exists!'
                ]
                return render_template('student/student_edit_page.html',
                                       form=form,
                                       form_name="Edit student")

        else:
            return render_template('student/student_edit_page.html',
                                   form=form,
                                   form_name="Edit student")