Commit 48b26b31 authored by Lukas Burgey's avatar Lukas Burgey

Fix a bug

The user of a NewDeployment can be None
parent bbc68672
......@@ -172,7 +172,9 @@ class NewDeployment(models.Model):
# credentials provided by the backend to the clients
@property
def credentials(self):
return self.user.credentials
if self.user is not None:
return self.user.credentials
return {}
@property
def state(self):
......@@ -306,7 +308,7 @@ class NewDeployment(models.Model):
# sends a state update via RabbitMQ / STOMP to the users webpage instance
def publish_to_user(self):
if self.user is None:
raise ValueError('Unable to publish deployment to None user')
return
# avoiding circular dependencies here
from .serializers.webpage import NewDeploymentSerializer
......@@ -559,14 +561,15 @@ class NewDeploymentStateItem(models.Model):
def _set_state(self, state, publish=True):
# assure all user credentials have a state
for key in self.parent.user.ssh_keys.all():
try:
CredentialState.get_credential_state(
credential=key,
target=self,
)
except CredentialState.DoesNotExist:
LOGGER.error('CredentialState.DoesNotExist in _set_state')
if self.parent.user is not None:
for key in self.parent.user.ssh_keys.all():
try:
CredentialState.get_credential_state(
credential=key,
target=self,
)
except CredentialState.DoesNotExist:
LOGGER.error('CredentialState.DoesNotExist in _set_state')
self.state = state
self.save()
......
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