Sort templates alphabetically
And also select the chosen template as the default one
This commit is contained in:
parent
768f3532f7
commit
a02c3c6973
2 changed files with 7 additions and 3 deletions
|
@ -92,10 +92,13 @@ class DCLCalculatorPlugin(CMSPluginBase):
|
||||||
if ids:
|
if ids:
|
||||||
context['templates'] = VMTemplate.objects.filter(
|
context['templates'] = VMTemplate.objects.filter(
|
||||||
vm_type=instance.vm_type
|
vm_type=instance.vm_type
|
||||||
).filter(opennebula_vm_template_id__in=ids)
|
).filter(opennebula_vm_template_id__in=ids).order_by('name')
|
||||||
else:
|
else:
|
||||||
context['templates'] = VMTemplate.objects.filter(
|
context['templates'] = VMTemplate.objects.filter(
|
||||||
vm_type=instance.vm_type
|
vm_type=instance.vm_type
|
||||||
|
).order_by('name')
|
||||||
|
context['default_selected_template'] = (
|
||||||
|
instance.default_selected_template
|
||||||
)
|
)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,8 @@
|
||||||
<label for="config">OS</label>
|
<label for="config">OS</label>
|
||||||
<select name="config">
|
<select name="config">
|
||||||
{% for template in templates %}
|
{% for template in templates %}
|
||||||
<option value="{{template.opennebula_vm_template_id}}">{{template.name}}</option>
|
|
||||||
|
<option value="{{template.opennebula_vm_template_id}}" {% if template.name|lower == default_selected_template|lower %}selected="selected"{% endif %}>{{template.name}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue