|
|
@ -54,6 +54,7 @@ class BidsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show_project
|
|
|
|
def show_project
|
|
|
|
|
|
|
|
# flash[:notice] = ""
|
|
|
|
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
|
|
|
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
|
|
|
@option = []
|
|
|
|
@option = []
|
|
|
|
@membership.each do |membership|
|
|
|
|
@membership.each do |membership|
|
|
|
@ -75,10 +76,18 @@ class BidsController < ApplicationController
|
|
|
|
def add
|
|
|
|
def add
|
|
|
|
project = Project.where('name = ?', params[:bid]).first
|
|
|
|
project = Project.where('name = ?', params[:bid]).first
|
|
|
|
bid_message = params[:bid_for_save][:bid_message]
|
|
|
|
bid_message = params[:bid_for_save][:bid_message]
|
|
|
|
BidingProject.cerate_bidding(@bid.id, project.id, bid_message)
|
|
|
|
if BidingProject.where("project_id = ? and bid_id = ?", project.id, @bid.id).size == 0
|
|
|
|
|
|
|
|
if BidingProject.cerate_bidding(@bid.id, project.id, bid_message)
|
|
|
|
|
|
|
|
flash[:notice] = l(:label_bidding_succeed)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
flash[:error] = l(:label_bidding_fail)
|
|
|
|
|
|
|
|
end
|
|
|
|
@bidding_project = @bid.biding_projects
|
|
|
|
@bidding_project = @bid.biding_projects
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
|
|
|
|
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
|
|
|
|
|
|
|
|
# format.html
|
|
|
|
|
|
|
|
format.html { redirect_to :back }
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
#format.api { render_api_ok }
|
|
|
|
#format.api { render_api_ok }
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -151,10 +160,20 @@ class BidsController < ApplicationController
|
|
|
|
##新建需求
|
|
|
|
##新建需求
|
|
|
|
def new_bid
|
|
|
|
def new_bid
|
|
|
|
if params[:bid_title]
|
|
|
|
if params[:bid_title]
|
|
|
|
|
|
|
|
if params[:bid_budget].to_s =~ /^(\d+)$|^(\d+).([0-9]{2})$/
|
|
|
|
|
|
|
|
if params[:bid_deadline].to_s =~ /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
|
|
|
|
bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description])
|
|
|
|
bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description])
|
|
|
|
end
|
|
|
|
|
|
|
|
unless bid.watched_by?(User.current)
|
|
|
|
unless bid.watched_by?(User.current)
|
|
|
|
bid.add_watcher(User.current)
|
|
|
|
if bid.add_watcher(User.current)
|
|
|
|
|
|
|
|
flash[:notice] = l(:label_bid_succeed)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
flash[:error] = l(:label_wrong_date)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
flash[:error] = l(:label_wrong_budget)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@limit = 5
|
|
|
|
@limit = 5
|
|
|
|
@bid_count = Bid.count
|
|
|
|
@bid_count = Bid.count
|
|
|
|