修改新建需求时提示错误信息功能

This commit is contained in:
fanqiang 2013-08-08 22:27:58 +08:00
parent a31f817e55
commit b2af215ee1
10 changed files with 60 additions and 34 deletions

View File

@ -54,6 +54,7 @@ class BidsController < ApplicationController
end
def show_project
# flash[:notice] = ""
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@option = []
@membership.each do |membership|
@ -75,10 +76,18 @@ class BidsController < ApplicationController
def add
project = Project.where('name = ?', params[:bid]).first
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
respond_to do |format|
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
# format.html
format.html { redirect_to :back }
format.js
#format.api { render_api_ok }
end
@ -151,10 +160,20 @@ class BidsController < ApplicationController
##新建需求
def new_bid
if params[:bid_title]
bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description])
end
unless bid.watched_by?(User.current)
bid.add_watcher(User.current)
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])
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
@limit = 5
@bid_count = Bid.count

View File

@ -13,6 +13,7 @@ class Bid < ActiveRecord::Base
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
validates_presence_of :author_id, :name, :deadline
validates_presence_of :deadline, :message => 'test'
# validates_format_of :deadline, :with =>
validate :validate_user

View File

@ -2,7 +2,7 @@
<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> <% 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'} %>
</div> <% end %></td>
</table>

View File

@ -7,8 +7,8 @@
height: 30px;
line-height: 18px;
font-size: 14px;
color: rgb(255, 255, 255);
background: url("../images/button/bg105.jpg") no-repeat scroll left top transparent;
color: rgb(119, 119, 119);
background: url("../images/button/bg103.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
@ -42,7 +42,7 @@
:remote => true,
:method => :post,
: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;
border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-top: 30px; margin-left: 30px;">
<tr>

View File

@ -1,7 +1,11 @@
<!-- fq -->
<table width="200px" border="0" style="padding-left: 15px">
<%= render_flash_messages %>
<table width="1000px" border="0" style="padding-left: 15px">
<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>
<% @bidding_project.each do |b_project|%>

View File

@ -1,3 +1,3 @@
$('#history').html('<%= escape_javascript(render(:partial => 'bids/history', :locals => {:bid => @bid, :journals => @jour, :state => true})) %>');
$('#bid_message_message').val("");
$('#bid_message_reference_user_id').val("");
$('#bid_message_reference_user_id').val("");

View File

@ -10,11 +10,11 @@
background: url("/images/button/bg104.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
/*margin-right: -4px;*/
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
/*margin-right: -4px;*/
}
input[type="button"].bid_btn {
width: 60px;
@ -25,11 +25,11 @@
background: url("/images/button/bg104.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
margin-right: -2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
margin-right: -2px;
}
textarea:focus {
border: #d5dee9 1px solid;
@ -55,12 +55,9 @@
$("#put-bid-form").hide();
}
</script>
<% if User.current.logged? %>
<div class="contextual">
<div class='icon icon-add' style="margin-right: 30px;">
<%= toggle_link l(:button_bidding), 'put-bid-form' %>
</div>
</div>
<div id = 'flash' style="float:left; width: 100%; display: none" ></div>
<div id="put-bid-form" style="display: none">
<%= form_for "bid_for_save", :remote=>true, :url => {:controller => 'bids', :action => 'add'},
:update => "bidding_project_list",
@ -74,11 +71,11 @@
:onfocus => "clearInfo('bid_message')", :onblur => "showInfo('bid_message')",
:value => "请输入应标理由", :style => "resize: none;", :class => 'noline'%></td>
</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'"%>
<%= 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>
</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'"%>
<%= 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>
</tr>
</table>
<% end %>
</div>

View File

@ -119,7 +119,7 @@
<%= render_menu :bid_menu %>
</div>
<% end %>
<%= render_flash_messages %>
<%= yield %>
<%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div>

View File

@ -20,7 +20,7 @@
<td colspan="2" width="580px" ><p class="font_description"><%= textilizable journal.notes%></p></td>
</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,
: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>

View File

@ -1174,4 +1174,9 @@ zh:
button_bidding: 我要应标
button_new_bid: 发布需求
label_user_information: "与我相关"
label_bid_succeed: "需求发布成功"
label_wrong_budget: 错误的金额格式
label_wrong_date: 时间格式错误,请输入正确的时间 yyyy-mm-dd
label_bidding_succeed: 应标成功
label_bidding_fail: 应标失败,该项目已经应标