Skip to content
Snippets Groups Projects
Commit e00d34ef authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Only use one file list.

parent 759a2936
No related branches found
No related tags found
No related merge requests found
...@@ -71,30 +71,27 @@ def job(job_id): ...@@ -71,30 +71,27 @@ def job(job_id):
elif not job.user_id == current_user.id: elif not job.user_id == current_user.id:
print('Job does not belong to current user.') print('Job does not belong to current user.')
abort(403) 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 = {} dir = os.path.join(current_app.config['OPAQUE_STORAGE'],
for file in os.listdir(input_dir): str(current_user.id),
'jobs',
str(job.id))
files = {}
for file in os.listdir(dir):
if file == 'output': if file == 'output':
continue continue
input_files[file] = os.path.join(input_dir, file) files[file] = {}
files[file]['path'] = os.path.join(dir, file)
output_files = {} if job.status == 'complete':
if job.status == 'complete': files[file]['results'] = {}
for input_file in input_files: results_dir = os.path.join(dir, 'output', file)
dir = os.path.join(output_dir, input_file) for result in os.listdir(results_dir):
for output_file in os.listdir(dir): files[file]['results'][result] = {}
output_files[output_file] = os.path.join(dir, output_file) files[file]['results'][result]['path'] = os.path.join(
results_dir, result
)
return render_template('main/jobs/job.html.j2', return render_template('main/jobs/job.html.j2',
input_files=input_files, files=files,
job=job, job=job,
output_files=output_files, title='Job') title='Job')
...@@ -71,23 +71,26 @@ ...@@ -71,23 +71,26 @@
</div> </div>
</div> </div>
<p> <p>
{% for file in input_files %} {% for file in files %}
<a href="file://{{ input_files[file] }}" class="waves-effect waves-light btn-small"> <a href="file://{{ files[file]['path'] }}" class="waves-effect waves-light btn-small">
<i class="material-icons left">file_download</i>{{ file }} <i class="material-icons left">file_download</i>{{ file }}
</a> </a>
{% endfor %} {% endfor %}
</p> </p>
{% if job.status == 'complete' %}
<p>&nbsp;</p> <p>&nbsp;</p>
<span class="card-title">Results</span> <span class="card-title">Results</span>
<p> <p>
{% for file in output_files %} {% for file in files %}
<a href="file://{{ output_files[file] }}" class="waves-effect waves-light btn-small"> {% for result in files[file]['results'] %}
<i class="material-icons left">file_download</i>{{ file }} <a href="file://{{ files[file]['results'][result]['path'] }}" class="waves-effect waves-light btn-small">
</a> <i class="material-icons left">file_download</i>{{ result }}
</a>
{% endfor %}
{% endfor %} {% endfor %}
</p> </p>
{% endif %}
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment