def delete_test(): if request.method == 'GET': return render_template('delete_test.html', tests=Test.get_all()) elif request.method == 'POST': test = Test.find(int(request.form['tests'])) test.delete() app.logger.info('Test "%s" was deleted successfully', request.form['tests']) return redirect('/homepage')
def edit_test(): if request.method == 'GET': return render_template('edit_test.html', tests=Test.get_all(), questions=Question.get_all()) elif request.method == 'POST': test = Test.find(int(request.form['tests'])) values = (request.form['title']) questions = [ Question.find(request.form['question_one']), Question.find(request.form['question_two']), Question.find(request.form['question_three']) ] test.update(values, questions).edit() app.logger.info("Test %s was succesfully edited", request.form['title']) return redirect('/homepage')
def show_tests(): # call static method get_all(), which returns the desired list return render_template('tests.html', tests=Test.get_all())