diff options
author | mahesh | 2017-11-23 01:11:59 +0530 |
---|---|---|
committer | mahesh | 2017-11-23 01:25:11 +0530 |
commit | ae4e2dad126535cda41a7b4a05fdb247f9cdf737 (patch) | |
tree | 4f0049a04e1645a0f5fd48e8d275d45a045aba74 /yaksh/views.py | |
parent | 7e2972786599fc23c436e593fcc236defd93c88c (diff) | |
download | online_test-ae4e2dad126535cda41a7b4a05fdb247f9cdf737.tar.gz online_test-ae4e2dad126535cda41a7b4a05fdb247f9cdf737.tar.bz2 online_test-ae4e2dad126535cda41a7b4a05fdb247f9cdf737.zip |
Render error output with django template instead of javascript
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index dd86e40..29f017e 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -662,19 +662,23 @@ def get_result(request, uid): result['status'] = result_state.get('status') if result['status'] == 'done': result = json.loads(result_state.get('result')) + template_path = os.path.join(*[os.path.dirname(__file__), + 'templates','yaksh', + 'error_template.html' + ] + ) + next_question, error_message, paper = _update_paper(request,uid, + result + ) if result.get('success'): - next_question, error_message, paper = _update_paper(request, - uid, result - ) return show_question(request, next_question, paper, error_message) - # else: - # with open(template_path) as f: - # template_data = f.read() - # template = Template(template_data) - # context = Context(result.get('error')[0]) - # render_error = template.render(context) - # print(render_error) - # result["error"] = render_error + else: + with open(template_path) as f: + template_data = f.read() + template = Template(template_data) + context = Context({"error_message": result.get('error')}) + render_error = template.render(context) + result["error"] = render_error return JsonResponse(result) |