# HG changeset patch # User Mads Kiilerich # Date 2019-12-30 01:38:59 # Node ID 44e18bd4c3b2402223d8267f79e5ff34f7e7135e # Parent 3cab6bc45cc39a7a622b2a1e662e233279e9c579 ssh: make it clear that SshKeyModel.delete has user as mandatory parameter It is already provided in the two uses: kallithea/controllers/admin/my_account.py: SshKeyModel().delete(fingerprint, request.authuser.user_id) kallithea/controllers/admin/users.py: SshKeyModel().delete(fingerprint, c.user.user_id) diff --git a/kallithea/model/ssh_key.py b/kallithea/model/ssh_key.py --- a/kallithea/model/ssh_key.py +++ b/kallithea/model/ssh_key.py @@ -72,17 +72,15 @@ class SshKeyModel(object): return new_ssh_key - def delete(self, fingerprint, user=None): + def delete(self, fingerprint, user): """ - Deletes ssh key with given fingerprint. If user is set, it also filters - the object for deletion by given user. + Deletes ssh key with given fingerprint for the given user. Will raise SshKeyModelException on errors """ ssh_key = UserSshKeys.query().filter(UserSshKeys.fingerprint == fingerprint) - if user: - user = User.guess_instance(user) - ssh_key = ssh_key.filter(UserSshKeys.user_id == user.user_id) + user = User.guess_instance(user) + ssh_key = ssh_key.filter(UserSshKeys.user_id == user.user_id) ssh_key = ssh_key.scalar() if ssh_key is None: