Commit 22d329d4 authored by Lukas Burgey's avatar Lukas Burgey

Check before accessing a nullable property

parent 95d81690
......@@ -199,7 +199,10 @@ class NewDeployment(models.Model):
@property
def services(self):
return self.vo.services.all()
if self.vo is not None:
return self.vo.services.all()
else:
return Service.objects.none()
@property
def sites(self):
......@@ -303,10 +306,11 @@ class NewDeployment(models.Model):
data = NewDeploymentSerializer(self).data
msg = dumps(data)
RabbitMQInstance.load().publish_by_vo(
self.vo,
msg,
)
if self.vo is not None:
RabbitMQInstance.load().publish_by_vo(
self.vo,
msg,
)
# sends a state update via RabbitMQ / STOMP to the users webpage instance
def publish_to_user(self):
......@@ -336,11 +340,17 @@ class NewDeployment(models.Model):
self.save()
def __str__(self):
return 'VO-Dep: ({}:{})#{}'.format(
self.vo,
self.user,
self.id,
)
if self.vo is not None:
return 'VO-Dep: ({}:{})#{}'.format(
self.vo,
self.user,
self.id,
)
else:
return 'VO-Dep: (!NO-VO!:{})#{}'.format(
self.user,
self.id,
)
class NewDeploymentStateItem(models.Model):
......
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