From a97935a8ace294e51cd4b7435f74b5e2ae694fa7 Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Fri, 2 Aug 2013 08:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E4=B8=AD=E7=9A=84=E5=85=B3=E6=B3=A8=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E7=95=8C=E9=9D=A2=EF=BC=8Curl=E4=B8=BAusers/:id/watch?= =?UTF-8?q?=5Fbids?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 5 ++-- app/controllers/users_controller.rb | 16 +++++++++-- app/helpers/watchers_helper.rb | 2 +- app/views/layouts/base_bids.html.erb | 2 +- app/views/users/watch_bids.html.erb | 41 ++++++++++++++++++++++++++++ config/routes.rb | 4 ++- 6 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 app/views/users/watch_bids.html.erb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 749d40a7..10b28271 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -3,7 +3,6 @@ class BidsController < ApplicationController before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add] helper :watchers - def index if params[:bid_title] Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description]) @@ -119,9 +118,9 @@ class BidsController < ApplicationController rescue ActiveRecord::RecordNotFound render_404 end - + def new_bid - + end def more diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 672c18d2..eedb307d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -17,8 +17,8 @@ class UsersController < ApplicationController layout 'base_users' - before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments] - before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments] + before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids] + before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids] accept_api_auth :index, :show, :create, :update, :destroy helper :sort @@ -62,6 +62,18 @@ class UsersController < ApplicationController end end + ##added by fq + def watch_bids + @bid = Bid.watched_by(@user) + + respond_to do |format| + format.html { + render :layout => 'base_users' + } + format.api + end + end + def user_activities #####fq diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index eef4ab73..264b5870 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -32,7 +32,7 @@ module WatchersHelper watched = objects.any? {|object| object.watched_by?(user)} css = [watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') - text = (objects.first.instance_of?(User) or objects.first.instance_of?(Project)) ? + text = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Bid))) ? (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) url = watch_path( diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb index e5aa2a08..94d1de53 100644 --- a/app/views/layouts/base_bids.html.erb +++ b/app/views/layouts/base_bids.html.erb @@ -66,7 +66,7 @@
- <%= render :partial => 'layouts/tag', :locals => {:obj => @bid,:object_flag => "4"}%> + <%= render :partial => 'layouts/tag', :locals => {:obj => @bid, :object_flag => "4"}%>
diff --git a/app/views/users/watch_bids.html.erb b/app/views/users/watch_bids.html.erb new file mode 100644 index 00000000..5d2b70e1 --- /dev/null +++ b/app/views/users/watch_bids.html.erb @@ -0,0 +1,41 @@ + + +
需求列表
+ +<% for bid in @bid%> + + + + + + +
<%= link_to image_tag(url_to_avatar(bid.author), :class => 'avatar'), :class => "avatar" %> + + + + + + + + + + + +
<%= link_to(bid.author, user_path(bid.author), :class => 'bid_user') %>:<%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
+ + + + + + + +
悬赏:¥<%= bid.budget%>(<%= bid.biding_projects.count%>)应标(<%= bid.commit %>)反馈(<%= bid.watcher_users.count%>)关注
<%= format_time bid.created_at %>
+
+ + + + +
<%= bid.description%>
+
+ +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index fd56217b..704998cb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,7 +73,8 @@ RedmineApp::Application.routes.draw do member do match 'user_projects', :to => 'users#user_projects', :via => :get, :as => "user_projects" match 'user_activities', :to => 'users#show', :via => :get, :as => "user_activities" - match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" + match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" + match 'watch_bids', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] end end #end @@ -420,6 +421,7 @@ RedmineApp::Application.routes.draw do match 'bids/:bid_id/show', :controller => 'bids', :action => 'show', :as => 'respond' match 'bids/new', :controller => 'bids', :action => 'new', :via => [:get , :post] + ########### added by liuping match 'tags/add_tag',:to => 'tags#add_tag',:as=>"add_tag"