diff --git a/app/controllers/project_packages_controller.rb b/app/controllers/project_packages_controller.rb index cdedea9e..3945f978 100644 --- a/app/controllers/project_packages_controller.rb +++ b/app/controllers/project_packages_controller.rb @@ -21,6 +21,10 @@ class ProjectPackagesController < ApplicationController render_react end + def apply_success + render_react + end + private def render_react render file: 'public/react/build/index.html', :layout => false diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4fae7ff7..3306326e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2558,6 +2558,56 @@ class UsersController < ApplicationController @tag = params[:tag] @objects = @objects.where(:course_list_id => params[:tag]).order("#{@sort} #{order}") end + when 'a_package' + bidding_packages = @user.bidding_project_packages + bidding_packages = bidding_packages.none if @show_all && params[:q] == 0 # 参与的不存在未发布的 + packages = @user.project_packages + + if @show_all + status = + case params[:q] + when '0' then %w(pending applying refused) + when '1' then %w(published) + when '2' then %w(bidding_ended bidding_finished) + end + if status.present? + packages = packages.where(status: status) + bidding_packages = bidding_packages.where(status: status) + end + else + packages = packages.where(status: %w(published bidding_ended bidding_finished)) + end + + ids = bidding_packages.pluck(:id) + packages.pluck(:id) + @objects = ProjectPackage.where(id: ids).order("published_at #{order}") + when 'p_package' + packages = @user.project_packages + if @show_all + status = + case params[:q] + when '0' then %w(pending applying refused) + when '1' then %w(published) + when '2' then %w(bidding_ended bidding_finished) + end + if status.present? + packages = packages.where(status: status) + end + else + packages = packages.where(status: %w(published bidding_ended bidding_finished)) + end + @objects = packages.order("published_at #{order}") + when 'l_package' + packages = @user.bidding_project_packages + if @show_all + status = + case params[:q] + when '0' then %w(bidding_lost) + when '1' then %w(bidding_won) + end + + packages = packages.where(bidding_users: { status: status }) if status.present? + end + @objects = packages.order("published_at #{order}") end @objects_count = @objects.size diff --git a/app/models/bidding_user.rb b/app/models/bidding_user.rb index 5869b6d4..9f368b2a 100644 --- a/app/models/bidding_user.rb +++ b/app/models/bidding_user.rb @@ -17,4 +17,8 @@ class BiddingUser < ActiveRecord::Base transitions from: [:pending], to: :bid_lost end end + + def status_text + I18n.t("bidding_user.status.#{status}") + end end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index b5545206..0e034d32 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -276,6 +276,8 @@ class User < Principal # 众包 has_many :project_packages, foreign_key: :creator_id, dependent: :destroy + has_many :bidding_users, dependent: :destroy + has_many :bidding_project_packages, through: :bidding_users, source: :project_package ## end diff --git a/app/views/users/_project_package.html.erb b/app/views/users/_project_package.html.erb new file mode 100644 index 00000000..d8ca475e --- /dev/null +++ b/app/views/users/_project_package.html.erb @@ -0,0 +1,82 @@ +<% if @type == 'p_package' && User.current == @user %> +