From 3f292c500ad49fca765dc6ead1fec702042e1a7f Mon Sep 17 00:00:00 2001 From: Johannes Brachem Date: Thu, 2 Apr 2020 15:37:41 +0200 Subject: [PATCH 01/15] Update __init__.py --- mortimer/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mortimer/__init__.py b/mortimer/__init__.py index b5e7ebe..29f0940 100644 --- a/mortimer/__init__.py +++ b/mortimer/__init__.py @@ -8,7 +8,6 @@ from flask_mail import Mail from flask_dropzone import Dropzone import pymongo -import alfred __version__ = '0.4.2' From 9b5f1a45f31c999cf74122100142558efca0a638 Mon Sep 17 00:00:00 2001 From: Johannes Brachem Date: Thu, 2 Apr 2020 16:27:41 +0200 Subject: [PATCH 02/15] Improve error handling Errors during script import are now handled properly, and an error handler for error 400 was added. --- mortimer/errors/handlers.py | 14 ++++++++++---- mortimer/templates/errors/400.html | 9 +++++++++ mortimer/web_experiments/alfredo.py | 7 ++++++- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 mortimer/templates/errors/400.html diff --git a/mortimer/errors/handlers.py b/mortimer/errors/handlers.py index d8dfc07..476894a 100644 --- a/mortimer/errors/handlers.py +++ b/mortimer/errors/handlers.py @@ -6,9 +6,9 @@ errors = Blueprint("erros", __name__) -@errors.app_errorhandler(404) -def error_404(error): - return render_template('errors/404.html'), 404 +@errors.app_errorhandler(400) +def error_400(error): + return render_template("errors/400.html"), 400 @errors.app_errorhandler(403) @@ -16,6 +16,12 @@ def error_403(error): return render_template('errors/403.html'), 403 +@errors.app_errorhandler(404) +def error_404(error): + return render_template('errors/404.html'), 404 + + @errors.app_errorhandler(500) def error_500(error): - return render_template('errors/500.html'), 500 + return render_template('errors/500_alfred.html'), 500 + diff --git a/mortimer/templates/errors/400.html b/mortimer/templates/errors/400.html new file mode 100644 index 0000000..22ed70a --- /dev/null +++ b/mortimer/templates/errors/400.html @@ -0,0 +1,9 @@ +{% extends "skeleton.html" %} + + +{% block layout %} +
+

Bad Request (400)

+

Something went wrong. Please try again later.

+
+{% endblock %} \ No newline at end of file diff --git a/mortimer/web_experiments/alfredo.py b/mortimer/web_experiments/alfredo.py index 6e059de..ceb60c3 100644 --- a/mortimer/web_experiments/alfredo.py +++ b/mortimer/web_experiments/alfredo.py @@ -4,6 +4,7 @@ import sys import importlib.util from flask import Blueprint, abort, request, session, url_for, redirect, make_response, flash, send_file, render_template, send_from_directory +from flask_login import current_user from threading import Lock from time import time from uuid import uuid4 @@ -147,7 +148,11 @@ def start(expid): module = import_script(experiment.id) except Exception as e: flash("Error during script import:\n'{e}'".format(e=e), 'danger') - return redirect(url_for('web_experiments.experiment', username=experiment.author, exp_title=experiment.title)) + logger.error(msg=traceback.format_exc(), exp_id=str(experiment.id), session_id=sid) + if current_user.is_authenticated: + return redirect(url_for('web_experiments.experiment', username=experiment.author, exp_title=experiment.title)) + else: + abort(500) try: script = Script() From f76f7be0e63a3eeb1caf9e65235a8ad081e75d8c Mon Sep 17 00:00:00 2001 From: Johannes Brachem Date: Thu, 2 Apr 2020 16:28:31 +0200 Subject: [PATCH 03/15] Update NEWS.md --- NEWS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.md b/NEWS.md index 65ff7c7..ae5e84e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# Mortimer v0.4.3 + +## Smaller changes + +* Improved error handling. + # Mortimer v0.4.2 ## Bugfixes From e78df323d9a15e72a47faae9f10937fe05bcc000 Mon Sep 17 00:00:00 2001 From: Johannes Brachem Date: Thu, 2 Apr 2020 16:38:35 +0200 Subject: [PATCH 04/15] Update config.py --- mortimer/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mortimer/config.py b/mortimer/config.py index d3ac65d..d46dd51 100644 --- a/mortimer/config.py +++ b/mortimer/config.py @@ -65,7 +65,7 @@ class Config: # Flask-Dropzone settings: DROPZONE_ALLOWED_FILE_CUSTOM = True - DROPZONE_ALLOWED_FILE_TYPE = ".pdf, image/*, .txt, .xml, .pem, .mp3, .mp4, .ogg" + DROPZONE_ALLOWED_FILE_TYPE = ".pdf, image/*, .txt, .xml, .pem, .mp3, .mp4, .ogg, .csv" DROPZONE_MAX_FILE_SIZE = 10 DROPZONE_MAX_FILES = 100 DROPZONE_UPLOAD_ON_CLICK = True From cc2b0ba9593f1fda660133b4ce53f6afa4eea480 Mon Sep 17 00:00:00 2001 From: Johannes Brachem Date: Fri, 3 Apr 2020 14:47:58 +0200 Subject: [PATCH 05/15] change navbar color --- mortimer/templates/layout.html | 15 +++++- mortimer/templates/layout_experiment.html | 58 +++++++++++------------ 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/mortimer/templates/layout.html b/mortimer/templates/layout.html index 7b93066..72e03ed 100644 --- a/mortimer/templates/layout.html +++ b/mortimer/templates/layout.html @@ -45,7 +45,7 @@

mortimer

v{{ v_morti
-
- +
+
+
+ Script +
+
+ +
+
+
+ + {% if experiment.description %} @@ -153,102 +165,18 @@
Description
Alfred versions used for data collection in this experiment: {% for v in alfred_versions %} - {{ v }} +{{ v }} {% endfor %} - - - - -
-
- {{ form.hidden_tag() }} -

{{ form.script.label() }}

-
-
- -
- -
- {% if form.version.errors %} - {{ form.version(class="form-control form-control-sm is-invalid") }} - -
- {% for error in form.version.errors %} - {{ error }} - {% endfor %} -
- - {% else %} - {{ form.version(class="form-control form-control-sm", placeholder=experiment.version) }} - {% endif %} -
-
- -
-
- - {{ form.script(class="form-control-file") }} - {% if form.script.errors %} - {% for error in form.script.errors %} - {{ error }}
- {% endfor %} - {% endif %} -
-
- - Changing the version number allows you to choose, for which versions of an experiment you want to download data. - If you made substantial changes to your experiment, you should change the version. - -
-
- {{ form.submit(class="btn btn-primary btn-sm", id="submit")}} -
-
-
- - -
-
+ + + {% endblock content %} From 9a04e398a0deccde76d4b34c6ab3d8f69fe77174 Mon Sep 17 00:00:00 2001 From: Johannes Brachem Date: Fri, 3 Apr 2020 14:57:52 +0200 Subject: [PATCH 08/15] make navbar unsticky --- mortimer/templates/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mortimer/templates/layout.html b/mortimer/templates/layout.html index 72e03ed..25ea154 100644 --- a/mortimer/templates/layout.html +++ b/mortimer/templates/layout.html @@ -45,7 +45,7 @@

mortimer

v{{ v_morti
-