From b2af215ee16e45e9b3d10b2bbbfbb4fd62c74374 Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Thu, 8 Aug 2013 22:27:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=BB=BA=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E6=97=B6=E6=8F=90=E7=A4=BA=E9=94=99=E8=AF=AF=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 29 +++++++++++++++++---- app/models/bid.rb | 1 + app/views/bids/_bid_show.html.erb | 2 +- app/views/bids/_new_bid.html.erb | 6 ++--- app/views/bids/_project_list.html.erb | 8 ++++-- app/views/bids/create.js.erb | 2 +- app/views/bids/show_project.html.erb | 37 ++++++++++++--------------- app/views/layouts/base_bids.html.erb | 2 +- app/views/words/_message.html.erb | 2 +- config/locales/zh.yml | 5 ++++ 10 files changed, 60 insertions(+), 34 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index f3786affc..9cec2946c 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -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 diff --git a/app/models/bid.rb b/app/models/bid.rb index 0a3016539..7f5d8a472 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -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 diff --git a/app/views/bids/_bid_show.html.erb b/app/views/bids/_bid_show.html.erb index e1fb7d581..3a1dc8f86 100644 --- a/app/views/bids/_bid_show.html.erb +++ b/app/views/bids/_bid_show.html.erb @@ -2,7 +2,7 @@
需求列表 <% if User.current.logged? %> -
+
<%= toggle_link l(:button_new_bid), 'put-bid-form', {:focus => 'project_id'} %>
<% end %>
diff --git a/app/views/bids/_new_bid.html.erb b/app/views/bids/_new_bid.html.erb index d7b9bc53f..44d8c228b 100644 --- a/app/views/bids/_new_bid.html.erb +++ b/app/views/bids/_new_bid.html.erb @@ -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' %> + diff --git a/app/views/bids/_project_list.html.erb b/app/views/bids/_project_list.html.erb index d52935114..5c8d29503 100644 --- a/app/views/bids/_project_list.html.erb +++ b/app/views/bids/_project_list.html.erb @@ -1,7 +1,11 @@ - -
+<%= render_flash_messages %> +
+
应标项目(<%= @bidding_project.count%>) +
+ <%= toggle_link l(:button_bidding), 'put-bid-form' %> +
<% @bidding_project.each do |b_project|%> diff --git a/app/views/bids/create.js.erb b/app/views/bids/create.js.erb index 197bfcdcb..d601d75b5 100644 --- a/app/views/bids/create.js.erb +++ b/app/views/bids/create.js.erb @@ -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(""); \ No newline at end of file +$('#bid_message_reference_user_id').val(""); diff --git a/app/views/bids/show_project.html.erb b/app/views/bids/show_project.html.erb index 50ca2bf91..2353026ba 100644 --- a/app/views/bids/show_project.html.erb +++ b/app/views/bids/show_project.html.erb @@ -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(); } + <% if User.current.logged? %> -
-
- <%= toggle_link l(:button_bidding), 'put-bid-form' %> -
-
+ diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb index 2de2b8e6a..f442e672e 100644 --- a/app/views/layouts/base_bids.html.erb +++ b/app/views/layouts/base_bids.html.erb @@ -119,7 +119,7 @@ <%= render_menu :bid_menu %> <% end %> - <%= render_flash_messages %> + <%= yield %> <%= call_hook :view_layouts_base_content %>
diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 06305a723..45c2d8df8 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -20,7 +20,7 @@

<%= textilizable journal.notes%>

- <%= journal.created_at %> + <%= formal_time journal.created_at %> <%= 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 %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 0ade9955a..52c9007b9 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -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: 应标失败,该项目已经应标