Merge pull request #668 from pcoder/task/5721/set_calculator_OS_order
Task/5721/set calculator OS order
This commit is contained in:
commit
32767fed68
4 changed files with 34 additions and 3 deletions
|
@ -354,3 +354,10 @@ class DCLCalculatorPluginModel(CMSPlugin):
|
||||||
"in the backend to be automatically listed in this "
|
"in the backend to be automatically listed in this "
|
||||||
"calculator instance."
|
"calculator instance."
|
||||||
)
|
)
|
||||||
|
default_selected_template = models.CharField(
|
||||||
|
default="Devuan Ascii",
|
||||||
|
null=True,
|
||||||
|
max_length=128,
|
||||||
|
help_text="Write the name of the template that you need selected as"
|
||||||
|
" default when the calculator loads"
|
||||||
|
)
|
||||||
|
|
|
@ -92,11 +92,14 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.4 on 2018-09-27 20:32
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('datacenterlight', '0025_dclnavbarpluginmodel_show_login_option'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='dclcalculatorpluginmodel',
|
||||||
|
name='default_selected_template',
|
||||||
|
field=models.CharField(default='Devuan Ascii', help_text='Write the name of the template that you need selected as default when the calculator loads', max_length=128, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -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