More elegant error handling
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
from ..forms.quiz import StartQuiz
 | 
			
		||||
from ..models import Entry, Test
 | 
			
		||||
from ..tools.forms import send_errors_to_client
 | 
			
		||||
from ..tools.test import redirect_if_started
 | 
			
		||||
 | 
			
		||||
from flask import abort, Blueprint, jsonify, redirect, render_template, request, session
 | 
			
		||||
@@ -52,8 +53,7 @@ def _start():
 | 
			
		||||
                    'id': entry.id
 | 
			
		||||
                }), 200
 | 
			
		||||
            return jsonify({'error': 'There was an error processing the user test and/or user codes.'}), 400
 | 
			
		||||
        errors = [*form.test_code.errors, *form.user_code.errors, *form.first_name.errors, *form.surname.errors, *form.email.errors, *form.club.errors]
 | 
			
		||||
        return jsonify({ 'error': errors}), 400
 | 
			
		||||
        return send_errors_to_client(form=form)
 | 
			
		||||
    return render_template('/quiz/start_quiz.html', form = form)
 | 
			
		||||
 | 
			
		||||
@quiz.route('/quiz/')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user