Only use one file list.

This commit is contained in:
Patrick Jentsch 2019-08-12 09:51:32 +02:00
parent 759a29362c
commit e00d34ef81
2 changed files with 28 additions and 28 deletions

View File

@ -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'],
dir = os.path.join(current_app.config['OPAQUE_STORAGE'],
str(current_user.id), str(current_user.id),
'jobs', 'jobs',
str(job.id)) str(job.id))
output_dir = os.path.join(current_app.config['OPAQUE_STORAGE'], files = {}
str(current_user.id), for file in os.listdir(dir):
'jobs',
str(job.id),
'output')
input_files = {}
for file in os.listdir(input_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':
for input_file in input_files: files[file]['results'] = {}
dir = os.path.join(output_dir, input_file) results_dir = os.path.join(dir, 'output', file)
for output_file in os.listdir(dir): for result in os.listdir(results_dir):
output_files[output_file] = os.path.join(dir, output_file) files[file]['results'][result] = {}
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')

View File

@ -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">
<i class="material-icons left">file_download</i>{{ result }}
</a> </a>
{% endfor %} {% endfor %}
{% endfor %}
</p> </p>
{% endif %}
</div> </div>
</div> </div>