Dockerised. Restructured to remove circular import
Moved most of app definitions out of guard function to use wsgi Updated configuration files and referencing of .env values. Local version needs dotenv or exporting of env variables. Dockerised version works fine without load_dotenv. Ready to test now!
This commit is contained in:
@ -8,7 +8,6 @@ from flask_mail import Message
|
||||
|
||||
from pymongo.collection import ReturnDocument
|
||||
|
||||
from main import app, db, mail
|
||||
from common.security import encrypt
|
||||
from common.data_tools import generate_questions, evaluate_answers
|
||||
from common.security.database import decrypt_find_one
|
||||
@ -24,6 +23,7 @@ views = Blueprint(
|
||||
@views.route('/')
|
||||
@views.route('/home/')
|
||||
def home():
|
||||
from main import db
|
||||
_id = session.get('_id')
|
||||
if _id and db.entries.find_one({'_id': _id}):
|
||||
return redirect(url_for('quiz_views.start_quiz'))
|
||||
@ -31,6 +31,7 @@ def home():
|
||||
|
||||
@views.route('/instructions/')
|
||||
def instructions():
|
||||
from main import db
|
||||
_id = session.get('_id')
|
||||
if _id and db.entries.find_one({'_id': _id}):
|
||||
return redirect(url_for('quiz_views.start_quiz'))
|
||||
@ -38,6 +39,7 @@ def instructions():
|
||||
|
||||
@views.route('/start/', methods = ['GET', 'POST'])
|
||||
def start():
|
||||
from main import db
|
||||
from .forms import StartQuiz
|
||||
form = StartQuiz()
|
||||
if request.method == 'GET':
|
||||
@ -85,6 +87,7 @@ def start():
|
||||
|
||||
@views.route('/api/questions/', methods=['POST'])
|
||||
def fetch_questions():
|
||||
from main import app, db
|
||||
_id = request.get_json()['_id']
|
||||
entry = db.entries.find_one({'_id': _id})
|
||||
if not entry:
|
||||
@ -124,6 +127,7 @@ def fetch_questions():
|
||||
|
||||
@views.route('/test/')
|
||||
def start_quiz():
|
||||
from main import db
|
||||
_id = session.get('_id')
|
||||
if not _id or not db.entries.find_one({'_id': _id}):
|
||||
flash('Your log in was not recognised. Please sign in to the quiz again.', 'error')
|
||||
@ -132,6 +136,7 @@ def start_quiz():
|
||||
|
||||
@views.route('/api/submit/', methods=['POST'])
|
||||
def submit_quiz():
|
||||
from main import app, db
|
||||
_id = request.get_json()['_id']
|
||||
answers = request.get_json()['answers']
|
||||
entry = db.entries.find_one({'_id': _id})
|
||||
@ -161,6 +166,7 @@ def submit_quiz():
|
||||
|
||||
@views.route('/result/')
|
||||
def result():
|
||||
from main import db, mail
|
||||
_id = session.get('_id')
|
||||
entry = decrypt_find_one(db.entries, {'_id': _id})
|
||||
if not entry:
|
||||
|
Reference in New Issue
Block a user