Merge remote-tracking branch 'origin/project_pack' into project_pack

project_pack
杨树明 5 years ago
commit 26794ea41f

@ -112,7 +112,7 @@ module Mobile
package = current_user.project_packages.new
::ProjectPackages::SaveService.new(package, symbolize_params).call
package.increment_visit_count!
render_ok
render_ok(id: package.id)
rescue ::ProjectPackages::SaveService::Error => ex
render_error(ex.message)
end
@ -142,7 +142,7 @@ module Mobile
::ProjectPackages::SaveService.new(package, symbolize_params).call
package.increment_visit_count!
render_ok
render_ok(id: package.id)
rescue ::ProjectPackages::SaveService::Error => ex
render_error(ex.message)
end

@ -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

@ -68,9 +68,13 @@ class ProjectPackage < ActiveRecord::Base
pending? || refused?
end
def deadline?
deadline_at < Time.now
end
def bidding_end?
flag = deadline_at < Time.now
end_bidding! if flag && can_end_bidding?
flag = deadline?
end_bidding! if flag && may_end_bidding?
flag
end

Loading…
Cancel
Save