添加了用户查找反馈的功能,可以查看对用户评论的引用和对用户需求的评论。解决了留言问题

This commit is contained in:
fanqiang 2013-08-06 22:26:52 +08:00
parent 836fe0b9a3
commit 4835cab6e4
25 changed files with 116 additions and 29 deletions

View File

@ -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{<pre>((.|\s)*?)</pre>}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

View File

@ -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

View File

@ -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{<pre>((.|\s)*?)</pre>}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

View File

@ -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))

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -6,14 +6,14 @@
<% unless state%>
<div class="contextual">
<%= link_to l(:button_more),
{:controller => 'bids', :action => 'more', :bid_id => bid},
{:controller => 'bids', :action => 'more', :id => bid},
:remote => true,
:method => 'get' %>
</div>
<% else %>
<div class="contextual">
<%= link_to l(:button_back),
{:controller => 'bids', :action => 'back', :bid_id => bid},
{:controller => 'bids', :action => 'back', :id => bid},
:remote => true,
:method => 'get' %>
</div>
@ -47,7 +47,7 @@
<tr>
<td align="left"><a class="font_lighter"> <%= journal.created_at %></a></td>
<td width="200" align="right" class="a"><%= 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 %></td>
</tr>
</table></td>

View File

@ -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|%>
<table border="0" width="525px" align="center" >
<tr>
<td><%= f.text_area 'message', :rows => 3, :cols => 65, :value => "我要反馈", :style => "resize: none;", :class => 'noline'%></td>
</tr></table>
<%= f.text_field :reference_user_id, :style=>"display:none"%>
<table border="0" width="525px" align="center">
<tr><td align="right"><%= 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'" %> </td></tr>

View File

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

View File

@ -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("");

View File

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

View File

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

View File

@ -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");

View File

@ -0,0 +1,36 @@
<!-- fq -->
<% unless @message.empty? %>
<div id="activity">
<% @message.sort {|x,y| y.created_at <=> x.created_at }.each do |e| -%>
<table width="660" border="0" align="left" style="border-bottom: 1px solid rgb(225, 225, 225); margin-bottom: 10px;">
<tr>
<!-- fq -->
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(e.user), :class => "avatar"), user_path(e.user), :class => "avatar" %></td>
<td>
<table width="580" border="0">
<tr>
<td colspan="2" valign="top"><strong> <%= link_to(h(e.user), user_path(e.user)) %></strong><span class="font_lighter">
<% 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 %>
</span></td>
</tr>
<tr>
<td colspan="2" width="580" >
<p class="font_description">
<%= textilizable e.notes %>
</p></td>
</tr>
<tr>
<td align="left"><a class="font_lighter"></a></td>
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_time e.created_at %></span></td>
</tr>
<!-- <tr><div class="line_under"></div></tr> -->
</table></td>
</tr>
</table>
<% end %>
</div>
<% end %>

View File

@ -33,4 +33,4 @@
</table>
<% end %>
</div>
<% end %>
<% end %>

View File

@ -7,6 +7,7 @@
:sta => sta}) do |f| %>
<p><%= label_tag 'user_message', l(:label_leave_message) %><%= f.text_area 'user_message', :rows => 3 %></p>
<%= f.text_field :reference_user_id, :style=>"display:none"%>
<p class="buttons">
<%= submit_tag l(:button_leave_meassge), :name => nil %>
<%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('user_message');", :type => 'button' %>

View File

@ -1 +1,2 @@
$('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => @state, :user => @user})) %>');
$('#new_form_reference_user_id').val("");

View File

@ -1,2 +1,3 @@
$('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => false, :user => @user})) %>');
$('#new_form_user_message').val("");
$('#new_form_user_message').val("");
$('#new_form_reference_user_id').val("");

View File

@ -1 +1,2 @@
$('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => false, :user => @user})) %>');
$('#new_form_reference_user_id').val("");

View File

@ -1 +1,2 @@
$('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => @state, :user => @user})) %>');
$('#new_form_reference_user_id').val("");

View File

@ -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");

View File

@ -1158,4 +1158,5 @@ zh:
label_bidding_project: 应标项目
button_bidding: 我要应标
button_new_bid: 发布需求
label_user_information: "与我相关"

View File

@ -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"

View File

@ -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