From a02c3c6973976ff6439081236ea0060463ff689d Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 27 Sep 2018 22:12:04 +0200 Subject: [PATCH] Sort templates alphabetically And also select the chosen template as the default one --- datacenterlight/cms_plugins.py | 7 +++++-- .../datacenterlight/includes/_calculator_form.html | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 95a496d8..b7841de8 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 + ) return context diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html index 72ca5a05..0a35e2ad 100644 --- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html +++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html @@ -91,7 +91,8 @@