Commit 6be09f81 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Clean up the deletion of ssh keys

parent 580739c0
......@@ -79,8 +79,7 @@ class SSHPublicKeyView(views.APIView):
# key state: -> (1), if there are no deployments
# key state: -> (5), if there are deployments
key.deleted = True
key.save()
key.delete_key()
return state_response(request)
elif request_type == 'add':
if 'key' in request.data:
......
......@@ -186,6 +186,15 @@ class SSHPublicKey(models.Model):
editable=False,
)
# does not directly delete the key, but merely starts the deletion process
# the receiver 'delete_old_ssh_key' does the actual deletion afterwards
def delete_key(self):
self.deleted = True
self.save()
for deployment in self.deployments.all():
deployment.withdraw_key(self)
def __str__(self):
if self.deleted:
return "DELETED: {}".format(self.name)
......
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