def add_student():
    """
    GET: returns add student formula
    POST: returns list of students with new student added
    """
    teams = Team.list_teams()
    if request.method == 'POST':
        save_student('add')
        flash('Student was added')
        return redirect(url_for('student_controller.list_students'))
    return render_template('student_form.html',
                           user=user_session(session['user'], session['type']),
                           teams=teams)
def edit_student(student_id):
    """
    Edit student formula to edit student details
    :param student_id: int
    GET return edit student formula
    POST return list of students with edited student changes saved
    """
    teams = Team.list_teams()
    student = Student.get_by_id(student_id)
    print('Editing')
    if student:
        if request.method == 'POST':
            save_student('edit', student.id)
            flash('Student was edited')
            return redirect(url_for('student_controller.list_students'))
        return render_template('edit_student_form.html',
                               user=user_session(session['user'],
                                                 session['type']),
                               student=student,
                               teams=teams)
    return redirect('list-students')
예제 #3
0
def list_teams():
    """Return viewteams.html with list of id teams and teams names."""
    teams = Team.list_teams()
    return render_template('viewteams.html',
                           user=user_session(session['user'], session['type']),
                           teams=teams)