修改新建需求时提示错误信息功能
This commit is contained in:
parent
a31f817e55
commit
b2af215ee1
|
@ -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]
|
||||||
bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description])
|
if params[:bid_budget].to_s =~ /^(\d+)$|^(\d+).([0-9]{2})$/
|
||||||
end
|
if params[:bid_deadline].to_s =~ /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
|
||||||
unless bid.watched_by?(User.current)
|
bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description])
|
||||||
bid.add_watcher(User.current)
|
unless bid.watched_by?(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
|
||||||
|
|
|
@ -13,6 +13,7 @@ class Bid < ActiveRecord::Base
|
||||||
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
|
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
|
||||||
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
|
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
|
||||||
validates_presence_of :author_id, :name, :deadline
|
validates_presence_of :author_id, :name, :deadline
|
||||||
|
validates_presence_of :deadline, :message => 'test'
|
||||||
# validates_format_of :deadline, :with =>
|
# validates_format_of :deadline, :with =>
|
||||||
validate :validate_user
|
validate :validate_user
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<table width="500px" border="0" style="padding-left: 10px; margin-bottom: 15px; padding-top: 10px;">
|
<table width="500px" border="0" style="padding-left: 10px; margin-bottom: 15px; padding-top: 10px;">
|
||||||
<td width="100px" class="font_lighter" style="font-size: 16px;">需求列表</td>
|
<td width="100px" class="font_lighter" style="font-size: 16px;">需求列表</td>
|
||||||
<td> <% if User.current.logged? %>
|
<td> <% if User.current.logged? %>
|
||||||
<div class='icon icon-add' >
|
<div class='icon icon-add'>
|
||||||
<%= toggle_link l(:button_new_bid), 'put-bid-form', {:focus => 'project_id'} %>
|
<%= toggle_link l(:button_new_bid), 'put-bid-form', {:focus => 'project_id'} %>
|
||||||
</div> <% end %></td>
|
</div> <% end %></td>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
height: 30px;
|
height: 30px;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: rgb(255, 255, 255);
|
color: rgb(119, 119, 119);
|
||||||
background: url("../images/button/bg105.jpg") no-repeat scroll left top transparent;
|
background: url("../images/button/bg103.jpg") no-repeat scroll left top transparent;
|
||||||
padding: 0px 0px 4px 0px;
|
padding: 0px 0px 4px 0px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
border: 1px solid rgb(148, 148, 148);
|
border: 1px solid rgb(148, 148, 148);
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
:remote => true,
|
:remote => true,
|
||||||
:method => :post,
|
:method => :post,
|
||||||
:id => 'new-bid-form'}) do %>
|
:id => 'new-bid-form'}) do %>
|
||||||
<%= error_messages_for 'bid' %>
|
|
||||||
<table border="0" width="600px" style="border-left: 1px solid #acaeb1; border-right: 1px solid #acaeb1;
|
<table border="0" width="600px" style="border-left: 1px solid #acaeb1; border-right: 1px solid #acaeb1;
|
||||||
border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-top: 30px; margin-left: 30px;">
|
border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-top: 30px; margin-left: 30px;">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
<!-- fq -->
|
<!-- fq -->
|
||||||
|
<%= render_flash_messages %>
|
||||||
<table width="200px" border="0" style="padding-left: 15px">
|
<table width="1000px" border="0" style="padding-left: 15px">
|
||||||
<td class="font_lighter" style="font-size: 18px;">应标项目(<%= @bidding_project.count%>)</td>
|
<td class="font_lighter" style="font-size: 18px;">应标项目(<%= @bidding_project.count%>)</td>
|
||||||
|
<td>
|
||||||
|
<div class='icon icon-add'>
|
||||||
|
<%= toggle_link l(:button_bidding), 'put-bid-form' %>
|
||||||
|
</div></td>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<% @bidding_project.each do |b_project|%>
|
<% @bidding_project.each do |b_project|%>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
$('#history').html('<%= escape_javascript(render(:partial => 'bids/history', :locals => {:bid => @bid, :journals => @jour, :state => true})) %>');
|
$('#history').html('<%= escape_javascript(render(:partial => 'bids/history', :locals => {:bid => @bid, :journals => @jour, :state => true})) %>');
|
||||||
$('#bid_message_message').val("");
|
$('#bid_message_message').val("");
|
||||||
$('#bid_message_reference_user_id').val("");
|
$('#bid_message_reference_user_id').val("");
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
background: url("/images/button/bg104.jpg") no-repeat scroll left top transparent;
|
background: url("/images/button/bg104.jpg") no-repeat scroll left top transparent;
|
||||||
padding: 0px 0px 4px 0px;
|
padding: 0px 0px 4px 0px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
border: 1px solid rgb(148, 148, 148);
|
border: 1px solid rgb(148, 148, 148);
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
margin-top: -10px;
|
margin-top: -10px;
|
||||||
/*margin-right: -4px;*/
|
/*margin-right: -4px;*/
|
||||||
}
|
}
|
||||||
input[type="button"].bid_btn {
|
input[type="button"].bid_btn {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
|
@ -25,11 +25,11 @@
|
||||||
background: url("/images/button/bg104.jpg") no-repeat scroll left top transparent;
|
background: url("/images/button/bg104.jpg") no-repeat scroll left top transparent;
|
||||||
padding: 0px 0px 4px 0px;
|
padding: 0px 0px 4px 0px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
border: 1px solid rgb(148, 148, 148);
|
border: 1px solid rgb(148, 148, 148);
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
margin-top: -10px;
|
margin-top: -10px;
|
||||||
margin-right: -2px;
|
margin-right: -2px;
|
||||||
}
|
}
|
||||||
textarea:focus {
|
textarea:focus {
|
||||||
border: #d5dee9 1px solid;
|
border: #d5dee9 1px solid;
|
||||||
|
@ -55,12 +55,9 @@
|
||||||
$("#put-bid-form").hide();
|
$("#put-bid-form").hide();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<% if User.current.logged? %>
|
<% if User.current.logged? %>
|
||||||
<div class="contextual">
|
<div id = 'flash' style="float:left; width: 100%; display: none" ></div>
|
||||||
<div class='icon icon-add' style="margin-right: 30px;">
|
|
||||||
<%= toggle_link l(:button_bidding), 'put-bid-form' %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="put-bid-form" style="display: none">
|
<div id="put-bid-form" style="display: none">
|
||||||
<%= form_for "bid_for_save", :remote=>true, :url => {:controller => 'bids', :action => 'add'},
|
<%= form_for "bid_for_save", :remote=>true, :url => {:controller => 'bids', :action => 'add'},
|
||||||
:update => "bidding_project_list",
|
:update => "bidding_project_list",
|
||||||
|
@ -74,11 +71,11 @@
|
||||||
:onfocus => "clearInfo('bid_message')", :onblur => "showInfo('bid_message')",
|
:onfocus => "clearInfo('bid_message')", :onblur => "showInfo('bid_message')",
|
||||||
:value => "请输入应标理由", :style => "resize: none;", :class => 'noline'%></td>
|
:value => "请输入应标理由", :style => "resize: none;", :class => 'noline'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="right"><%= submit_tag l(:button_add), :name => nil , :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -30px'"%>
|
<td align="right"><%= submit_tag l(:button_add), :name => nil , :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -30px'"%>
|
||||||
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'",
|
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'",
|
||||||
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %> </td>
|
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
<%= render_menu :bid_menu %>
|
<%= render_menu :bid_menu %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= render_flash_messages %>
|
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
<%= call_hook :view_layouts_base_content %>
|
<%= call_hook :view_layouts_base_content %>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<td colspan="2" width="580px" ><p class="font_description"><%= textilizable journal.notes%></p></td>
|
<td colspan="2" width="580px" ><p class="font_description"><%= textilizable journal.notes%></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left"><a class="font_lighter"> <%= journal.created_at %></a></td>
|
<td align="left"><a class="font_lighter"> <%= formal_time journal.created_at %></a></td>
|
||||||
<td width="200" align="right" class="a"><%= link_to(image_tag('comment.png'), {:controller => 'words', :action => 'new', :id => user, :journal_id => journal}, :remote => true,
|
<td width="200" align="right" class="a"><%= link_to(image_tag('comment.png'), {:controller => 'words', :action => 'new', :id => user, :journal_id => journal}, :remote => true,
|
||||||
:method => 'post', :title => l(:button_quote))%><%= link_to(image_tag('delete.png'), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user},
|
:method => 'post', :title => l(:button_quote))%><%= link_to(image_tag('delete.png'), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user},
|
||||||
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) if remove_allowed || journal.jour_id == User.current.id %></td>
|
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) if remove_allowed || journal.jour_id == User.current.id %></td>
|
||||||
|
|
|
@ -1174,4 +1174,9 @@ zh:
|
||||||
button_bidding: 我要应标
|
button_bidding: 我要应标
|
||||||
button_new_bid: 发布需求
|
button_new_bid: 发布需求
|
||||||
label_user_information: "与我相关"
|
label_user_information: "与我相关"
|
||||||
|
label_bid_succeed: "需求发布成功"
|
||||||
|
label_wrong_budget: 错误的金额格式
|
||||||
|
label_wrong_date: 时间格式错误,请输入正确的时间 yyyy-mm-dd
|
||||||
|
label_bidding_succeed: 应标成功
|
||||||
|
label_bidding_fail: 应标失败,该项目已经应标
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue