Filter context templates also by the ids that have been set for the calculator

This commit is contained in:
PCoder 2018-06-13 11:53:43 +02:00
parent 94f520be35
commit b872777bda

View file

@ -88,9 +88,15 @@ class DCLCalculatorPlugin(CMSPluginBase):
context = super(DCLCalculatorPlugin, self).render(
context, instance, placeholder
)
context['templates'] = VMTemplate.objects.filter(
vm_type=instance.vm_type
)
ids = instance.pricing.vm_templates_to_show
if ids:
context['templates'] = VMTemplate.objects.filter(
vm_type=instance.vm_type
).filter(opennebula_vm_template_id__in=ids)
else:
context['templates'] = VMTemplate.objects.filter(
vm_type=instance.vm_type
)
return context