|
|
|
@ -20,14 +20,6 @@ module Mobile
|
|
|
|
|
package.published_at.try(:utc).try(:iso8601)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
expose :can_bidding, if: { type: :show } do |package, opts|
|
|
|
|
|
package.can_bidding?(opts[:user])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
expose :can_select_bidding_user, if: { type: :show } do |package, opts|
|
|
|
|
|
opts[:user].id == package.creator_id && !package.bidding_end?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
expose :creator, if: { type: :show } do |package, _|
|
|
|
|
|
{
|
|
|
|
|
id: package.creator.id,
|
|
|
|
@ -60,6 +52,19 @@ module Mobile
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
expose :operation, if: { type: :show } do |package, opts|
|
|
|
|
|
user = opts[:user]
|
|
|
|
|
is_creator = user.id == package.creator_id
|
|
|
|
|
is_admin = user.admin? || user.business?
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
can_bidding: package.can_bidding?(user),
|
|
|
|
|
can_select_bidding_user: package.bidding_end? && package.end_bidding? && (is_creator || is_admin),
|
|
|
|
|
can_edit: package.editable? && (is_creator || is_admin),
|
|
|
|
|
can_delete: package.deletable? && (is_creator || is_admin)
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|