Add get_vm_pricing_by_name VMPricing method

This commit is contained in:
PCoder 2018-04-15 20:55:39 +02:00
parent 63a12ffe06
commit 962c96067f
1 changed files with 12 additions and 0 deletions

View File

@ -45,6 +45,18 @@ class VMPricing(models.Model):
if not self.vat_inclusive else 'NO_VAT', ]
)
@classmethod
def get_vm_pricing_by_name(cls, name):
try:
pricing = VMPricing.objects.get(name=name)
except Exception as e:
logger.error(
"Error getting VMPricing with name {name}. "
"Details: {details}".format(name=name, details=str(e))
)
pricing = VMPricing.get_default_pricing()
return pricing
@classmethod
def get_default_pricing(cls):
""" Returns the default pricing or None """