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

Fix a bug

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