from flask.helpers import flash
from data.sources import sources
from flask import flash
def validate_questions(submissions):
for key in submissions:
if 'q' in key and int(key[1:]):
return True
flash('Error: You cannot leave the quiz blank.', category='error')
return False
def validate_filters(submissions):
if not set.intersection(set(submissions.keys()), set(sources.keys())):
flash('Error: You must select at least one source book to show results from.', category='error')
return False
else:
return True
def validate_submissions(submissions):
if validate_questions(submissions) and validate_filters(submissions):
return True
else:
return False