2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-03 07:54:10 -04:00
|
|
|
class DeploymentEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id
|
|
|
|
expose :iid
|
|
|
|
expose :sha
|
|
|
|
|
|
|
|
expose :ref do
|
|
|
|
expose :name do |deployment|
|
|
|
|
deployment.ref
|
|
|
|
end
|
2017-04-24 16:34:36 -04:00
|
|
|
|
|
|
|
expose :ref_path do |deployment|
|
2017-06-29 13:06:35 -04:00
|
|
|
project_tree_path(deployment.project, id: deployment.ref)
|
2017-04-24 16:34:36 -04:00
|
|
|
end
|
2016-11-03 07:54:10 -04:00
|
|
|
end
|
|
|
|
|
2017-03-28 06:48:53 -04:00
|
|
|
expose :created_at
|
2016-11-03 07:54:10 -04:00
|
|
|
expose :tag
|
|
|
|
expose :last?
|
2017-04-24 16:34:36 -04:00
|
|
|
|
|
|
|
expose :user, using: UserEntity
|
|
|
|
expose :commit, using: CommitEntity
|
2017-06-07 05:36:41 -04:00
|
|
|
expose :deployable, using: JobEntity
|
2019-02-08 07:53:35 -05:00
|
|
|
expose :manual_actions, using: JobEntity, if: -> (*) { can_create_deployment? }
|
|
|
|
expose :scheduled_actions, using: JobEntity, if: -> (*) { can_create_deployment? }
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_create_deployment?
|
|
|
|
can?(request.current_user, :create_deployment, request.project)
|
|
|
|
end
|
2016-11-03 07:54:10 -04:00
|
|
|
end
|