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):
if self.user is not None:
return self.user.credentials 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,6 +561,7 @@ class NewDeploymentStateItem(models.Model): ...@@ -559,6 +561,7 @@ 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
if self.parent.user is not None:
for key in self.parent.user.ssh_keys.all(): for key in self.parent.user.ssh_keys.all():
try: try:
CredentialState.get_credential_state( CredentialState.get_credential_state(
......
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