536a47b4b7
[10.3] Migrate `can_push` column from `keys` to `deploy_keys_project` See merge request gitlab/gitlabhq!2276 (cherry picked from commit f6ca52d31bac350a23938e0aebf717c767b4710c) 1f2bd3c0 Backport to 10.3
22 lines
667 B
Ruby
22 lines
667 B
Ruby
class DeployKeyEntity < Grape::Entity
|
|
expose :id
|
|
expose :user_id
|
|
expose :title
|
|
expose :fingerprint
|
|
expose :destroyed_when_orphaned?, as: :destroyed_when_orphaned
|
|
expose :almost_orphaned?, as: :almost_orphaned
|
|
expose :created_at
|
|
expose :updated_at
|
|
expose :deploy_keys_projects, using: DeployKeysProjectEntity do |deploy_key|
|
|
deploy_key.deploy_keys_projects
|
|
.without_project_deleted
|
|
.select { |deploy_key_project| Ability.allowed?(options[:user], :read_project, deploy_key_project.project) }
|
|
end
|
|
expose :can_edit
|
|
|
|
private
|
|
|
|
def can_edit
|
|
Ability.allowed?(options[:user], :update_deploy_key, object)
|
|
end
|
|
end
|