mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-14 10:00:40 +00:00
Unify job input tables
This commit is contained in:
@ -1,28 +0,0 @@
|
||||
from flask_table import Table, Col, LinkCol
|
||||
|
||||
|
||||
class JobInputTable(Table):
|
||||
"""
|
||||
Declares the table describing colum by column.
|
||||
"""
|
||||
classes = ['highlight', 'responsive-table']
|
||||
filename = Col('Filename', column_html_attrs={'class': 'filename'},
|
||||
th_html_attrs={'class': 'sort',
|
||||
'data-sort': 'filename'})
|
||||
url = LinkCol('Download', 'jobs.download_job_input',
|
||||
url_kwargs=dict(job_id='job.id',
|
||||
job_input_id='input_id'),
|
||||
anchor_attrs={'class': 'waves-effect waves-light btn-floating',
|
||||
'download': ''},
|
||||
text_fallback='<i class="material-icons">file_download</i>')
|
||||
|
||||
|
||||
class JobInputItem(object):
|
||||
"""
|
||||
Describes one item like one row per table.
|
||||
"""
|
||||
|
||||
def __init__(self, filename, job, input_id):
|
||||
self.filename = filename
|
||||
self.job = job
|
||||
self.input_id = input_id
|
@ -3,10 +3,8 @@ from flask import (abort, current_app, flash, redirect, render_template,
|
||||
from flask_login import current_user, login_required
|
||||
from . import jobs
|
||||
from . import tasks
|
||||
from . tables import JobInputItem, JobInputTable
|
||||
from ..models import Job, JobInput, JobResult
|
||||
import os
|
||||
import html
|
||||
|
||||
|
||||
@jobs.route('/<int:job_id>')
|
||||
@ -15,15 +13,13 @@ def job(job_id):
|
||||
job = Job.query.get_or_404(job_id)
|
||||
if not (job.creator == current_user or current_user.is_administrator()):
|
||||
abort(403)
|
||||
items = [JobInputItem(input.filename, job, input.id)
|
||||
for input in job.inputs]
|
||||
# Convert table object to html string and unescape <>& for al little hack to use icons in buttons
|
||||
job_input_table = html.unescape(JobInputTable(items).__html__())
|
||||
# Add class "list" to tbody element. Needed for "List.js"
|
||||
job_input_table = job_input_table.replace('tbody', 'tbody class="list"', 1)
|
||||
job_inputs = [dict(filename=input.filename,
|
||||
id=input.id,
|
||||
job_id=job.id)
|
||||
for input in job.inputs]
|
||||
return render_template('jobs/job.html.j2',
|
||||
job=job,
|
||||
job_input_table=job_input_table,
|
||||
job_inputs=job_inputs,
|
||||
title='Job')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user