diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 187b2ade..b13a097f 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -1,7 +1,7 @@ # fq class BidsController < ApplicationController - before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add] + before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add, :new] helper :watchers def index @@ -86,7 +86,8 @@ class BidsController < ApplicationController def create if params[:bid_message].size>0 message = params[:bid_message][:message] - @bid.add_jour(User.current, message) + refer_user_id = params[:bid_message][:reference_user_id].to_i + @bid.add_jour(User.current, message, refer_user_id) # if a_message.size > 5 # @message = a_message[-5, 5] # else @@ -137,6 +138,7 @@ class BidsController < ApplicationController text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') @content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" + @id = user.id rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 63b0bda9..e54c1c61 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, :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] + before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info] + before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info] accept_api_auth :index, :show, :create, :update, :destroy helper :sort @@ -148,8 +148,10 @@ class UsersController < ApplicationController ### modified by fq def show + #####fq @message = MessagesForUser.find_message(@user.id) + JournalsForMessage.reference_message(@user.id) # show projects based on current user visibility @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current)) if @user == User.current @@ -181,6 +183,27 @@ class UsersController < ApplicationController ##end fq + #### added by fq + def info + @message = [] + if @user == User.current + @message = JournalsForMessage.reference_message(@user.id) + end + + unless User.current.admin? + if !@user.active? + render_404 + return + end + end + + respond_to do |format| + format.html + format.api + end + end + #### end + def new @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) @auth_sources = AuthSource.all diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index ab7d7f9a..e978b1d3 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -2,12 +2,13 @@ class WordsController < ApplicationController before_filter :find_user, :only => [:new, :create, :destroy, :more, :back] - def create if params[:new_form][:user_message].size>0 unless params[:user_id].nil? message = params[:new_form][:user_message] - @user.add_jour(User.current, message) + refer_user_id = params[:new_form][:reference_user_id].to_i + + @user.add_jour(User.current, message, refer_user_id) # if a_message.size > 5 # @message = a_message[-5, 5] # else @@ -23,7 +24,7 @@ class WordsController < ApplicationController # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} format.js #format.api { render_api_ok } - end + end end def destroy @@ -57,6 +58,7 @@ class WordsController < ApplicationController text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') @content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" + @id = user.id rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index fcd253c8..99154e75 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -14,7 +14,7 @@ module BidsHelper url = {:controller => 'bids', :action => 'destroy', :object_id => journal, - :bid_id => bid} + :id => bid} links << ' ' links << link_to(image_tag('delete.png'), url, :remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) diff --git a/app/models/bid.rb b/app/models/bid.rb index ccc6247f..0a301653 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -40,8 +40,8 @@ class Bid < ActiveRecord::Base acts_as_activity_provider :find_options => {:include => [:author]}, :author_key => :author_id - def add_jour(user, notes) - self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes) + def add_jour(user, notes, reference_user_id = 0) + self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) end def self.creat_bids(budget, deadline, name, description=nil) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index c3085d1c..2d53be81 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -10,4 +10,14 @@ class JournalsForMessage < ActiveRecord::Base self.delete_all "id = #{message_id}" end + def reference_user + User.find(reply_id) + end + + def self.reference_message(user_id) + @user = User.find(user_id) + message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))", ) + message + end + end diff --git a/app/models/user.rb b/app/models/user.rb index e4667f72..6e720c06 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -90,7 +90,7 @@ class User < Principal #end #####fq has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy - has_many :bids, :dependent => :destroy + has_many :bids, :foreign_key => 'author_id', :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy ##### @@ -143,9 +143,9 @@ class User < Principal scope :sorted, lambda { order(*User.fields_for_order_statement)} - ###添加留言 - def add_jour(user, notes) - self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes) + ###添加留言 fq + def add_jour(user, notes, reference_user_id = 0) + self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) end def set_mail_notification diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb index 3df9bc99..6bc784d3 100644 --- a/app/views/bids/_history.html.erb +++ b/app/views/bids/_history.html.erb @@ -6,14 +6,14 @@ <% unless state%>
<%= link_to l(:button_more), - {:controller => 'bids', :action => 'more', :bid_id => bid}, + {:controller => 'bids', :action => 'more', :id => bid}, :remote => true, :method => 'get' %>
<% else %>
<%= link_to l(:button_back), - {:controller => 'bids', :action => 'back', :bid_id => bid}, + {:controller => 'bids', :action => 'back', :id => bid}, :remote => true, :method => 'get' %>
@@ -47,7 +47,7 @@ <%= journal.created_at %> <%= link_to(image_tag('comment.png'), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true, - :method => 'post', :title => l(:button_quote))%><%= link_to(image_tag('delete.png'), {:controller => 'bids', :action => 'destroy', :object_id => journal, :bid_id => bid}, + :method => 'post', :title => l(:button_quote))%><%= link_to(image_tag('delete.png'), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid}, :remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) if remove_allowed || journal.user_id == User.current.id %> diff --git a/app/views/bids/_new.html.erb b/app/views/bids/_new.html.erb index caf046b7..d203603d 100644 --- a/app/views/bids/_new.html.erb +++ b/app/views/bids/_new.html.erb @@ -38,12 +38,13 @@ <%= form_for('bid_message', :remote => true, :method => :post, :url => {:controller => 'bids', :action => 'create', - :bid_id => bid, + :id => bid, :sta => sta}) do |f|%>
<%= f.text_area 'message', :rows => 3, :cols => 65, :value => "我要反馈", :style => "resize: none;", :class => 'noline'%>
+ <%= f.text_field :reference_user_id, :style=>"display:none"%> diff --git a/app/views/bids/back.js.erb b/app/views/bids/back.js.erb index b2d3c515..56272cd1 100644 --- a/app/views/bids/back.js.erb +++ b/app/views/bids/back.js.erb @@ -1 +1,2 @@ $('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:bid => @bid, :journals => @jour, :state => @state})) %>'); +$('#bid_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/bids/create.js.erb b/app/views/bids/create.js.erb index 15cf3f20..197bfcdc 100644 --- a/app/views/bids/create.js.erb +++ b/app/views/bids/create.js.erb @@ -1,2 +1,3 @@ $('#history').html('<%= escape_javascript(render(:partial => 'bids/history', :locals => {:bid => @bid, :journals => @jour, :state => true})) %>'); -$('#user_message_message').val(""); +$('#bid_message_message').val(""); +$('#bid_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/bids/destroy.js.erb b/app/views/bids/destroy.js.erb index c5e1516b..ca73a347 100644 --- a/app/views/bids/destroy.js.erb +++ b/app/views/bids/destroy.js.erb @@ -1 +1,2 @@ $('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:bid => @bid, :journals => @jour, :state => false})) %>'); +$('#bid_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/bids/more.js.erb b/app/views/bids/more.js.erb index b2d3c515..56272cd1 100644 --- a/app/views/bids/more.js.erb +++ b/app/views/bids/more.js.erb @@ -1 +1,2 @@ $('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:bid => @bid, :journals => @jour, :state => @state})) %>'); +$('#bid_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/bids/new.js.erb b/app/views/bids/new.js.erb index 2a4df8a6..5a74ec22 100644 --- a/app/views/bids/new.js.erb +++ b/app/views/bids/new.js.erb @@ -1,2 +1,3 @@ -$('#user_message_message').val("<%= raw escape_javascript(@content) %>"); -showAndScrollTo("user_message", "user_message"); +$('#bid_message_message').val("<%= raw escape_javascript(@content) %>"); +$('#bid_message_reference_user_id').val("<%= @id%>"); +showAndScrollTo("bid_message", "bid_message"); diff --git a/app/views/users/info.html.erb b/app/views/users/info.html.erb new file mode 100644 index 00000000..6a91e08b --- /dev/null +++ b/app/views/users/info.html.erb @@ -0,0 +1,36 @@ + +<% unless @message.empty? %> +
+ <% @message.sort {|x,y| y.created_at <=> x.created_at }.each do |e| -%> +
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -30px'"%> <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('bid_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
+ + + + + +
<%= link_to image_tag(url_to_avatar(e.user), :class => "avatar"), user_path(e.user), :class => "avatar" %> + + + + + + + + + + + + +
<%= link_to(h(e.user), user_path(e.user)) %> + <% if e.jour_type == "Bid"%> + 对需求:<%= link_to(e.jour.name, respond_path(e.jour))%>进行了反馈 + <% elsif e.jour_type == 'Principal' %> + 对<%= link_to("我", user_path(e.jour))%>的话进行了引用 + <% end %> +
+

+ <%= textilizable e.notes %> +

<%= format_time e.created_at %>
+ <% end %> + +<% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c924f8d1..4bfc4b07 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -33,4 +33,4 @@ <% end %> -<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/words/_new.html.erb b/app/views/words/_new.html.erb index 4d2b0a7c..8c007a32 100644 --- a/app/views/words/_new.html.erb +++ b/app/views/words/_new.html.erb @@ -7,6 +7,7 @@ :sta => sta}) do |f| %>

<%= label_tag 'user_message', l(:label_leave_message) %><%= f.text_area 'user_message', :rows => 3 %>

+ <%= f.text_field :reference_user_id, :style=>"display:none"%>

<%= submit_tag l(:button_leave_meassge), :name => nil %> <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('user_message');", :type => 'button' %> diff --git a/app/views/words/back.js.erb b/app/views/words/back.js.erb index 17c8aa9b..fa06ff48 100644 --- a/app/views/words/back.js.erb +++ b/app/views/words/back.js.erb @@ -1 +1,2 @@ $('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => @state, :user => @user})) %>'); +$('#new_form_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/words/create.js.erb b/app/views/words/create.js.erb index fa0798a5..823587b3 100644 --- a/app/views/words/create.js.erb +++ b/app/views/words/create.js.erb @@ -1,2 +1,3 @@ $('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => false, :user => @user})) %>'); -$('#new_form_user_message').val(""); \ No newline at end of file +$('#new_form_user_message').val(""); +$('#new_form_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index d1eeb4d5..f2030b78 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -1 +1,2 @@ $('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => false, :user => @user})) %>'); +$('#new_form_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/words/more.js.erb b/app/views/words/more.js.erb index 17c8aa9b..fa06ff48 100644 --- a/app/views/words/more.js.erb +++ b/app/views/words/more.js.erb @@ -1 +1,2 @@ $('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => @state, :user => @user})) %>'); +$('#new_form_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/words/new.js.erb b/app/views/words/new.js.erb index 16fabe66..dc8290a0 100644 --- a/app/views/words/new.js.erb +++ b/app/views/words/new.js.erb @@ -1,2 +1,3 @@ -$('#new_form_user_message').val("<%= raw escape_javascript(@content) %>"); +$('#new_form_user_message').val("<%= raw escape_javascript(@content)%>"); +$('#new_form_reference_user_id').val("<%= @id %>"); showAndScrollTo("new_form_user_message", "new_form_user_message"); diff --git a/config/locales/zh.yml b/config/locales/zh.yml index addafbc4..e1caac4f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1158,4 +1158,5 @@ zh: label_bidding_project: 应标项目 button_bidding: 我要应标 button_new_bid: 发布需求 + label_user_information: "与我相关" diff --git a/config/routes.rb b/config/routes.rb index 8144504c..3de86ade 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -75,6 +75,7 @@ RedmineApp::Application.routes.draw do match 'user_activities', :to => 'users#show', :via => :get, :as => "user_activities" match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" match 'watch_bids', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] + match 'info', :to => 'users#info', :via => [:get , :post], :as => 'user_info' end end #end @@ -407,22 +408,20 @@ RedmineApp::Application.routes.draw do delete 'words/destroy', :to => 'words#destroy' get 'words/more', :to => 'words#more' get 'words/back', :to=> 'words#back' - ############## + ############## fq post 'bids/create', :to => 'bids#create' delete 'bids/destroy', :to => 'bids#destroy' + match 'bids/new', :controller => 'bids', :action => 'new', :via => [:get , :post] get 'bids/more', :to => 'bids#more' get 'bids/back', :to=> 'bids#back' + match 'bids/new_bid', :controller => 'bids', :action => 'new_bid' match 'bids/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' match 'bids/:id/add', :controller => 'bids', :action => 'add' - match 'bids/new_bid', :controller => 'bids', :action => 'new_bid' # added by young match 'bids', :controller => 'bids', :action => 'index' match 'bids/:id', :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" match 'tags/delete_tag',:to => 'tags#delete_tag',:as=>"add_tag" diff --git a/lib/redmine.rb b/lib/redmine.rb index a752c816..e672e660 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -267,9 +267,11 @@ end #added by young Redmine::MenuManager.map :user_menu do |menu| menu.push :activity, {:controller => 'users', :action => 'show' } + menu.push :user_information, {:controller => 'users', :action => 'info'} menu.push :project, {:controller => 'users', :action => 'user_projects'} menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback'} + end #end