diff --git a/Changelog b/Changelog index db20e920..190a7af8 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ -Next: +2.2.2: 2018-09-28 + * #5721: Set calculator OS list in alphabetical order and set `Devuan Ascii` as the default (PR #668) * bugfix: Fix some typos and correct DE translations (PR #667) 2.2.1: 2018-09-25 * feature: Change DCLNavbarPlugin to show login option only if set (PR #665) diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index 3a8297b5..2d1a98b5 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -354,4 +354,11 @@ class DCLCalculatorPluginModel(CMSPlugin): "in the backend to be automatically listed in this " "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" + ) enable_512mb_ram = models.BooleanField(default=False) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 404f3181..af32e64f 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -92,11 +92,14 @@ class DCLCalculatorPlugin(CMSPluginBase): if ids: context['templates'] = VMTemplate.objects.filter( vm_type=instance.vm_type - ).filter(opennebula_vm_template_id__in=ids) + ).filter(opennebula_vm_template_id__in=ids).order_by('name') else: context['templates'] = VMTemplate.objects.filter( vm_type=instance.vm_type - ) + ).order_by('name') + context['default_selected_template'] = ( + instance.default_selected_template + ) context['min_ram'] = 0.5 if instance.enable_512mb_ram else 1 return context diff --git a/datacenterlight/migrations/0026_dclcalculatorpluginmodel_default_selected_template.py b/datacenterlight/migrations/0026_dclcalculatorpluginmodel_default_selected_template.py new file mode 100644 index 00000000..047d4096 --- /dev/null +++ b/datacenterlight/migrations/0026_dclcalculatorpluginmodel_default_selected_template.py @@ -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), + ), + ] diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html index eed79e27..f7deb13f 100644 --- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html +++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html @@ -92,7 +92,8 @@