Skip to content
Snippets Groups Projects
Commit 9405aa0b authored by Martin Mareš's avatar Martin Mareš
Browse files

Stránka s detaily jobu

parent 336084a3
No related branches found
No related tags found
3 merge requests!19Reforma vyhodnocování práv,!18Dávky okolo feedbacku,!17Výsledkovka pomocí mo.web.table
This commit is part of merge request !17. Comments created here will be created in the context of that merge request.
......@@ -50,6 +50,27 @@ def org_jobs():
)
@app.route('/org/jobs/<int:id>/')
def org_job(id: int):
sess = db.get_session()
job = sess.query(db.Job).options(joinedload(db.Job.user)).get(id)
if job is None:
return werkzeug.exceptions.NotFound()
if not (job.user_id == g.user.user_id or g.user.is_org):
return werkzeug.exceptions.Forbidden()
has_errors = (job.state == db.JobState.failed
and isinstance(job.out_json, dict)
and 'errors' in job.out_json)
return render_template(
'org_job.html',
job=job, db=db,
has_errors=has_errors,
)
@app.route('/org/jobs/<int:id>/output')
def org_job_output(id: int):
sess = db.get_session()
......
{% extends "base.html" %}
{% block head %}
<meta http-equiv=refresh content=30>
{% endblock %}
{% block body %}
<h2>Dávka #{{ job.job_id }}</h2>
<table class=data>
<tr><th>Název<td>{{ job.description }}
<tr><th>Vlastník<td>{{ job.user.full_name() }}
<tr><th>Stav<td>{{ job.state.friendly_name() }}
<tr><th>Zpráva<td>{{ job.result|or_dash }}
<tr><th>Vytvořena<td>{{ job.created_at|time_and_timedelta }}
<tr><th>Dokončena<td>{{ job.finished_at|time_and_timedelta }}
<tr><th>Vyprší<td>{{ job.expires_at|time_and_timedelta }}
</table>
{% if has_errors %}
<h3>Chyby</h3>
<pre><div class="alert alert-danger" role="alert">{{ "" -}}
{% for e in job.out_json['errors'] %}
{{ e }}
{% endfor %}
</div></pre>
{% endif %}
{% if job.out_file %}
<a class='btn btn-xs btn-primary' href='{{ url_for('org_job_output', id=job.job_id) }}'>Stáhnout výstup</a>
{% endif %}
{% endblock %}
......@@ -31,11 +31,13 @@ dávku po stažení výstupu smažete sami – šetří to místo na serveru.
<td>{{ j.description }}
<td>{{ j.created_at|timeformat }}
<td><b>{{ j.state.friendly_name() }}</b>{% if j.finished_at != None %} {{ j.finished_at|timedelta }}{% endif %}
{%- if j.result != "" %}<br>{{ j.result }}{% endif %}
<td>{% if j.expires_at %}{{ j.expires_at|timedelta}}{% endif %}
{% if g.user.is_admin %}<td>{{ j.user.full_name() }}{% endif %}
<td>
<div class='btn-group'><form action="" method="POST" class="btn-group">
{{ form_delete_job.csrf_token() }}
<a class='btn btn-xs btn-primary' href='{{ url_for('org_job', id=j.job_id) }}'>Detail</a>
{% if j.out_file %}
<a class='btn btn-xs btn-primary' href='{{ url_for('org_job_output', id=j.job_id) }}'>Výsledek</a>
{% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment