Throw validation error if no build outputs have been started

This commit is contained in:
Oliver Walters 2022-02-01 15:58:18 +11:00
parent 318e84883a
commit 00d7cf88e8
2 changed files with 6 additions and 0 deletions

View File

@ -437,6 +437,9 @@ class Build(MPTTModel, ReferenceIndexingMixin):
def output_count(self):
return self.build_outputs.count()
def has_build_outputs(self):
return self.output_count > 0
def get_build_outputs(self, **kwargs):
"""
Return a list of build outputs.

View File

@ -284,6 +284,9 @@ class BuildCompleteSerializer(serializers.Serializer):
if build.incomplete_count > 0:
raise ValidationError(_("Build order has incomplete outputs"))
if not build.has_build_outputs():
raise ValidationError(_("No build outputs have been created for this build order"))
return data
def save(self):