rrs/models: handle All missing in milestones

If we call objects.get() with no matching record then the result will be
an exception, not a null return, so handle that properly.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-03-20 16:34:25 +13:00
parent b8f51c7f9e
commit 24db787f68

View File

@ -14,6 +14,7 @@ from datetime import date
from django.db import models
from django.contrib.auth.models import User
from layerindex.models import Recipe, LayerBranch
from django.core.exceptions import ObjectDoesNotExist
class MaintenancePlan(models.Model):
@ -78,7 +79,10 @@ class Milestone(models.Model):
milestones = []
today = date.today()
mall = Milestone.objects.get(release__plan=maintplan, release__name=release_name, name='All')
try:
mall = Milestone.objects.get(release__plan=maintplan, release__name=release_name, name='All')
except ObjectDoesNotExist:
mall = None
if mall:
milestones.append(mall)