Commit 4da1239d authored by Lukas Burgey's avatar Lukas Burgey

Fix a bug in create_state_items

Previously if a service had no sites and no site was manually given
create_state_items failed. We now ignore such services.
parent 0a7206e5
......@@ -216,9 +216,17 @@ class NewDeployment(models.Model):
for service in self.services:
LOGGER.debug('create_state_items: creating NewDeploymentStateItem for service %s at sites %s', service, service.site.all())
if site is None:
if not service.site.exists():
raise ValueError('Cannot create state item for service without site')
if site is not None:
NewDeploymentStateItem.get_state_item(
parent=self,
site=site,
service=service,
).save()
return
else:
# if not service.site.exists():
# raise ValueError('Cannot create state item for service without site')
for service_site in service.site.all():
# LOGGER.debug('create_state_items: creating NewDeploymentStateItems for service %s at site %s', service, service_site)
......@@ -227,12 +235,6 @@ class NewDeployment(models.Model):
site=service_site,
service=service,
).save()
else:
NewDeploymentStateItem.get_state_item(
parent=self,
site=site,
service=service,
).save()
@classmethod
def get_deployment(cls, user, service=None, group=None, site=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment