2018-07-19 18:43:13 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-24 10:11:36 +00:00
|
|
|
class DeployKeyEntity < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :user_id
|
|
|
|
expose :title
|
|
|
|
expose :fingerprint
|
2017-04-07 11:34:39 +00:00
|
|
|
expose :destroyed_when_orphaned?, as: :destroyed_when_orphaned
|
|
|
|
expose :almost_orphaned?, as: :almost_orphaned
|
2017-03-24 10:11:36 +00:00
|
|
|
expose :created_at
|
|
|
|
expose :updated_at
|
2018-01-05 15:23:44 +00:00
|
|
|
expose :deploy_keys_projects, using: DeployKeysProjectEntity do |deploy_key|
|
2019-08-01 16:18:17 +00:00
|
|
|
deploy_key.deploy_keys_projects.select do |deploy_key_project|
|
|
|
|
!deploy_key_project.project&.pending_delete? &&
|
|
|
|
Ability.allowed?(options[:user], :read_project, deploy_key_project.project)
|
|
|
|
end
|
2017-03-24 10:11:36 +00:00
|
|
|
end
|
2017-03-31 12:54:38 +00:00
|
|
|
expose :can_edit
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_edit
|
2018-01-05 15:23:44 +00:00
|
|
|
Ability.allowed?(options[:user], :update_deploy_key, object)
|
2017-03-31 12:54:38 +00:00
|
|
|
end
|
2017-03-24 10:11:36 +00:00
|
|
|
end
|