diff --git a/app/main/views.py b/app/main/views.py index 732f2eff92527cd8b97395229d7a7fd5310cfa39..0bd21894cddcfa9763bae48fb18d230ab1df81d2 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -71,30 +71,27 @@ def job(job_id): elif not job.user_id == current_user.id: print('Job does not belong to current user.') abort(403) - input_dir = os.path.join(current_app.config['OPAQUE_STORAGE'], - str(current_user.id), - 'jobs', - str(job.id)) - output_dir = os.path.join(current_app.config['OPAQUE_STORAGE'], - str(current_user.id), - 'jobs', - str(job.id), - 'output') - input_files = {} - for file in os.listdir(input_dir): + dir = os.path.join(current_app.config['OPAQUE_STORAGE'], + str(current_user.id), + 'jobs', + str(job.id)) + files = {} + for file in os.listdir(dir): if file == 'output': continue - input_files[file] = os.path.join(input_dir, file) - - output_files = {} - if job.status == 'complete': - for input_file in input_files: - dir = os.path.join(output_dir, input_file) - for output_file in os.listdir(dir): - output_files[output_file] = os.path.join(dir, output_file) + files[file] = {} + files[file]['path'] = os.path.join(dir, file) + if job.status == 'complete': + files[file]['results'] = {} + results_dir = os.path.join(dir, 'output', file) + for result in os.listdir(results_dir): + files[file]['results'][result] = {} + files[file]['results'][result]['path'] = os.path.join( + results_dir, result + ) return render_template('main/jobs/job.html.j2', - input_files=input_files, + files=files, job=job, - output_files=output_files, title='Job') + title='Job') diff --git a/app/templates/main/jobs/job.html.j2 b/app/templates/main/jobs/job.html.j2 index 0a8aad5f6006125fed7c410080e68d7b1a62d761..66b2214e323c168f5c13dd8f7ab1d0bd6df0049f 100644 --- a/app/templates/main/jobs/job.html.j2 +++ b/app/templates/main/jobs/job.html.j2 @@ -71,23 +71,26 @@ </div> </div> <p> - {% for file in input_files %} - <a href="file://{{ input_files[file] }}" class="waves-effect waves-light btn-small"> + {% for file in files %} + <a href="file://{{ files[file]['path'] }}" class="waves-effect waves-light btn-small"> <i class="material-icons left">file_download</i>{{ file }} </a> {% endfor %} </p> + {% if job.status == 'complete' %} <p> </p> - <span class="card-title">Results</span> <p> - {% for file in output_files %} - <a href="file://{{ output_files[file] }}" class="waves-effect waves-light btn-small"> - <i class="material-icons left">file_download</i>{{ file }} - </a> + {% for file in files %} + {% for result in files[file]['results'] %} + <a href="file://{{ files[file]['results'][result]['path'] }}" class="waves-effect waves-light btn-small"> + <i class="material-icons left">file_download</i>{{ result }} + </a> + {% endfor %} {% endfor %} </p> + {% endif %} </div> </div>