forked from ungleich-public/dynamicweb
fix cms dependencies
This commit is contained in:
parent
6b21b86ffe
commit
fa97ef8593
3 changed files with 22 additions and 14 deletions
|
|
@ -13,6 +13,7 @@ from filer.fields.file import FilerFileField
|
|||
from filer.fields.image import FilerImageField
|
||||
|
||||
from datacenterlight.models import VMPricing, VMTemplate
|
||||
from django.db.utils import OperationalError, ProgrammingError
|
||||
|
||||
|
||||
class CMSIntegration(models.Model):
|
||||
|
|
@ -316,17 +317,22 @@ class MultipleChoiceArrayField(ArrayField):
|
|||
vm_template_choices = []
|
||||
|
||||
if settings.OPENNEBULA_DOMAIN != 'test_domain':
|
||||
vm_template_choices = [
|
||||
(
|
||||
str(obj.opennebula_vm_template_id),
|
||||
try:
|
||||
vm_template_choices = [
|
||||
(
|
||||
obj.name + ' - ' + VMTemplate.IPV6.title()
|
||||
if obj.vm_type == VMTemplate.IPV6
|
||||
else obj.name
|
||||
),
|
||||
)
|
||||
for obj in VMTemplate.objects.all()
|
||||
]
|
||||
str(obj.opennebula_vm_template_id),
|
||||
(
|
||||
obj.name + ' - ' + VMTemplate.IPV6.title()
|
||||
if obj.vm_type == VMTemplate.IPV6
|
||||
else obj.name
|
||||
),
|
||||
)
|
||||
for obj in VMTemplate.objects.all()
|
||||
]
|
||||
except (ProgrammingError, OperationalError):
|
||||
# The VMTemplate table may not exist yet, e.g. during
|
||||
# migrations or initial application setup.
|
||||
vm_template_choices = []
|
||||
|
||||
defaults = {
|
||||
'form_class': forms.MultipleChoiceField,
|
||||
|
|
@ -335,7 +341,6 @@ class MultipleChoiceArrayField(ArrayField):
|
|||
|
||||
defaults.update(kwargs)
|
||||
|
||||
# Skip ArrayField.formfield() because we don't need its implementation.
|
||||
return super(ArrayField, self).formfield(**defaults)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue