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

fix default selected queues in forms

- WebappCreate -> select the queue that has is_default==True
- JobCreate -> select Webapp.job_queue
parent 2d573a20
Pipeline #40846 failed with stage
in 1 minute and 23 seconds
......@@ -174,15 +174,13 @@ class WebappForm(forms.ModelForm):
# Advanced
docker_os = forms.ModelChoiceField(
queryset=DockerOs.objects.all().distinct(),
initial=1,
label='Operating sytem',
label_suffix='')
memory_limit_mb = forms.IntegerField(label="Memory limit", label_suffix='',
initial=config.env.ALLGO_WEBAPP_DEFAULT_MEMORY_LIMIT_MB,
min_value=0)
job_queue = forms.ModelChoiceField(
queryset=JobQueue.objects.all().distinct(),
initial=1,
queryset=JobQueue.objects.all().distinct().order_by("timeout"),
label='Default job queue',
label_suffix='')
entrypoint = forms.CharField(label="Entrypoint", label_suffix="",
......@@ -191,6 +189,9 @@ class WebappForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(WebappForm, self).__init__(*args, **kwargs)
self.instance.job_queue = JobQueue.objects.filter(
is_default=True).first()
for field in self.fields.values():
field.error_messages = {'required':'The field "{fieldname}" is required'.format(
fieldname=field.label)}
......
......@@ -95,7 +95,9 @@
<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 | fancy_job_queue }}</option>
<option value="{{ choice.pk }}"
{% if choice.pk == form.instance.job_queue_id %} selected {% endif %}
>{{ choice | fancy_job_queue }}</option>
{% endfor %}
</select>
</div>
......
......@@ -117,7 +117,9 @@
<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 | fancy_job_queue }}</option>
<option value="{{ choice.pk }}"
{% if choice.pk == webapp.job_queue_id %} selected {% endif %}
>{{ 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