Commit f9b2cd9c authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

display timeout when choosing a job queue

parent 73cc4deb
from datetime import datetime
import json
import shlex
from django import template
from django.utils.safestring import mark_safe
from django.utils.timesince import timesince
from misaka import Markdown, HtmlRenderer, EXT_SUPERSCRIPT, EXT_FENCED_CODE, EXT_AUTOLINK
from main.models import Job
......@@ -37,6 +39,22 @@ def fancy_name(webapp_name):
""" Replace underscores by spaces """
return webapp_name.replace('_', ' ')
@register.filter(name='fancy_job_queue')
def fancy_job_queue(queue):
"""Display the queue name with its timeout (if any)"""
if queue.timeout is None:
return queue.name
if queue.timeout < 60:
return "%s (<%d seconds)" % (queue.name, queue.timeout)
else:
return "%s (<%s)" % (queue.name, timesince(
datetime.fromtimestamp(0),
datetime.fromtimestamp(queue.timeout)))
_JOB_STATUS_RENDER_VALUES = {
"NEW": ("New job", "fas fa-plus picto-green"),
......
{% extends "base.html" %}
{% load htmlattrs %}
{% load htmlattrs converters %}
{% block title %}Create a webapp{% endblock %}
......@@ -95,7 +95,7 @@
<select name="{{ form.job_queue.name }}" id="{{ form.job_queue.id_for_label }}" class="form-control">
{% for choice in form.job_queue.field.queryset %}
<option value="{{ choice.pk }}">{{ choice.name }}</option>
<option value="{{ choice.pk }}">{{ choice | fancy_job_queue }}</option>
{% endfor %}
</select>
</div>
......
......@@ -117,7 +117,7 @@
<select name="{{ form.queue_id.name }}" id="{{ form.queue_id.id_for_label }}" class="form-control">
{% for choice in form.queue_id.field.queryset %}
<option value="{{ choice.pk }}">{{ choice.name }}</option>
<option value="{{ choice.pk }}">{{ choice | fancy_job_queue }}</option>
{% endfor %}
</select>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment