diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-12-27 18:00:49 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-12-27 18:00:49 +0300 |
commit | 20afb4c69ee91a91094eed2bffd566c5bca1ce0d (patch) | |
tree | 632bbb3e3e8978a8d7bb2e26dd91edf9b83ecd4d /app/models | |
parent | cdb29c2fb00a873e8f8f646b06c7b000cc13e610 (diff) | |
parent | c1d11bf57c3091aa4695e302e21c39b9ec723f54 (diff) |
Merge branch 'feature/1376-allow-write-access-deploy-keys' into 'master'
Allow to add deploy keys with write-access
Closes #1376
See merge request !7383
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/deploy_key.rb | 14 | ||||
-rw-r--r-- | app/models/key.rb | 8 |
2 files changed, 18 insertions, 4 deletions
diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb index 2c525d4cd7a..053f2a11aa0 100644 --- a/app/models/deploy_key.rb +++ b/app/models/deploy_key.rb @@ -20,4 +20,18 @@ class DeployKey < Key def destroyed_when_orphaned? self.private? end + + def has_access_to?(project) + projects.include?(project) + end + + def can_push_to?(project) + can_push? && has_access_to?(project) + end + + private + + # we don't want to notify the user for deploy keys + def notify_user + end end diff --git a/app/models/key.rb b/app/models/key.rb index a5d25409730..6f377f0e8ae 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -57,10 +57,6 @@ class Key < ActiveRecord::Base ) end - def notify_user - run_after_commit { NotificationService.new.new_key(self) } - end - def post_create_hook SystemHooksService.new.execute_hooks_for(self, :create) end @@ -86,4 +82,8 @@ class Key < ActiveRecord::Base self.fingerprint = Gitlab::KeyFingerprint.new(self.key).fingerprint end + + def notify_user + run_after_commit { NotificationService.new.new_key(self) } + end end |