2017-03-24 06:11:36 -04:00
|
|
|
class DeployKeyEntity < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :user_id
|
|
|
|
expose :title
|
|
|
|
expose :fingerprint
|
|
|
|
expose :can_push
|
2017-04-07 07:34:39 -04:00
|
|
|
expose :destroyed_when_orphaned?, as: :destroyed_when_orphaned
|
|
|
|
expose :almost_orphaned?, as: :almost_orphaned
|
2017-03-24 06:11:36 -04:00
|
|
|
expose :created_at
|
|
|
|
expose :updated_at
|
|
|
|
expose :projects, using: ProjectEntity do |deploy_key|
|
2017-07-25 13:15:45 -04:00
|
|
|
deploy_key.projects.without_deleted.select { |project| options[:user].can?(:read_project, project) }
|
2017-03-24 06:11:36 -04:00
|
|
|
end
|
2017-03-31 08:54:38 -04:00
|
|
|
expose :can_edit
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_edit
|
|
|
|
options[:user].can?(:update_deploy_key, object)
|
|
|
|
end
|
2017-03-24 06:11:36 -04:00
|
|
|
end
|