Move initialization of VMTemplates out of the plugin
This commit is contained in:
parent
79e83b4480
commit
70cac38f81
2 changed files with 16 additions and 17 deletions
|
@ -300,20 +300,6 @@ class MultipleChoiceArrayField(ArrayField):
|
||||||
Uses Django's Postgres ArrayField
|
Uses Django's Postgres ArrayField
|
||||||
and a MultipleChoiceField for its formfield.
|
and a MultipleChoiceField for its formfield.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def formfield(self, **kwargs):
|
|
||||||
defaults = {
|
|
||||||
'form_class': forms.MultipleChoiceField,
|
|
||||||
'choices': self.base_field.choices,
|
|
||||||
}
|
|
||||||
defaults.update(kwargs)
|
|
||||||
# Skip our parent's formfield implementation completely as we don't
|
|
||||||
# care for it.
|
|
||||||
# pylint:disable=bad-super-call
|
|
||||||
return super(ArrayField, self).formfield(**defaults)
|
|
||||||
|
|
||||||
|
|
||||||
class DCLCalculatorPluginModel(CMSPlugin):
|
|
||||||
VMTemplateChoices = list(
|
VMTemplateChoices = list(
|
||||||
(
|
(
|
||||||
str(obj.opennebula_vm_template_id),
|
str(obj.opennebula_vm_template_id),
|
||||||
|
@ -323,6 +309,20 @@ class DCLCalculatorPluginModel(CMSPlugin):
|
||||||
)
|
)
|
||||||
for obj in VMTemplate.objects.all()
|
for obj in VMTemplate.objects.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def formfield(self, **kwargs):
|
||||||
|
defaults = {
|
||||||
|
'form_class': forms.MultipleChoiceField,
|
||||||
|
'choices': self.VMTemplateChoices,
|
||||||
|
}
|
||||||
|
defaults.update(kwargs)
|
||||||
|
# Skip our parent's formfield implementation completely as we don't
|
||||||
|
# care for it.
|
||||||
|
# pylint:disable=bad-super-call
|
||||||
|
return super(ArrayField, self).formfield(**defaults)
|
||||||
|
|
||||||
|
|
||||||
|
class DCLCalculatorPluginModel(CMSPlugin):
|
||||||
pricing = models.ForeignKey(
|
pricing = models.ForeignKey(
|
||||||
VMPricing,
|
VMPricing,
|
||||||
related_name="dcl_custom_pricing_vm_pricing",
|
related_name="dcl_custom_pricing_vm_pricing",
|
||||||
|
@ -337,7 +337,6 @@ class DCLCalculatorPluginModel(CMSPlugin):
|
||||||
base_field=models.CharField(
|
base_field=models.CharField(
|
||||||
blank=True,
|
blank=True,
|
||||||
max_length=256,
|
max_length=256,
|
||||||
choices=VMTemplateChoices
|
|
||||||
),
|
),
|
||||||
default=list,
|
default=list,
|
||||||
blank=True,
|
blank=True,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.9.4 on 2018-06-24 06:54
|
# Generated by Django 1.9.4 on 2018-06-24 08:23
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import datacenterlight.cms_models
|
import datacenterlight.cms_models
|
||||||
|
@ -16,6 +16,6 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='dclcalculatorpluginmodel',
|
model_name='dclcalculatorpluginmodel',
|
||||||
name='vm_templates_to_show',
|
name='vm_templates_to_show',
|
||||||
field=datacenterlight.cms_models.MultipleChoiceArrayField(base_field=models.CharField(blank=True, choices=[('4', 'CentOS 7'), ('14', 'Debian 8'), ('25', 'Ubuntu 14.04'), ('26', 'Ubuntu 16.04'), ('36', 'Devuan Jessie'), ('65', 'Devuan Ascii'), ('69', 'FreeBSD 11.1')], max_length=256), blank=True, default=list, help_text='Recommended: If you wish to show all templates of the corresponding VM Type (public/ipv6only), please do not select any of the items in the above field. This will allow any new template(s) added in the backend to be automatically listed in this calculator instance.', size=None),
|
field=datacenterlight.cms_models.MultipleChoiceArrayField(base_field=models.CharField(blank=True, max_length=256), blank=True, default=list, help_text='Recommended: If you wish to show all templates of the corresponding VM Type (public/ipv6only), please do not select any of the items in the above field. This will allow any new template(s) added in the backend to be automatically listed in this calculator instance.', size=None),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue