From 0be6e3602036cadebb99830580847b6428c58188 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Jan 2016 21:07:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E3=80=81=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E3=80=81=E4=B8=AA=E4=BA=BA=E7=95=99=E8=A8=80=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=9A=84=E7=82=B9=E8=B5=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/praise_tread_controller.rb | 48 ++++++++++++------- .../organizations/_org_course_news.html.erb | 21 ++++++-- .../organizations/_org_project_issue.html.erb | 21 ++++++-- app/views/projects/_project_news.html.erb | 21 ++++++-- app/views/users/_course_news.html.erb | 21 ++++++-- app/views/users/_project_issue.html.erb | 21 ++++++-- .../users/_user_journalsformessage.html.erb | 21 ++++++-- 7 files changed, 136 insertions(+), 38 deletions(-) diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index fdd33485d..b99963e2f 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -5,21 +5,26 @@ class PraiseTreadController < ApplicationController def praise_plus @obj = nil - # @is_in_list = nil - if @pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first - - end @activity = false + if request.get? + @obj_id = params[:obj_id] + @obj_type = params[:obj_type] if !params[:user_activity_id].nil? && !params[:type].nil? @user_activity_id = params[:user_activity_id] @type = params[:type] @activity = true end - @obj_id = params[:obj_id] - @obj_type = params[:obj_type] - #@horizontal = params[:horizontal].downcase == "false" ? false:true + # @is_in_list = nil @obj = find_object_by_type_and_id(@obj_type,@obj_id) + pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id) + unless pts.empty? + respond_to do |format| + format.js + end + return + end + #@horizontal = params[:horizontal].downcase == "false" ? false:true if @obj.respond_to?("author_id") author_id = @obj.author_id elsif @obj.respond_to?("user_id") @@ -39,13 +44,24 @@ class PraiseTreadController < ApplicationController @activity = false if request.get? #@obj = params[:obj] # 传的是对象,最后变成id了 - @obj_id = params[:obj_id] - @obj_type = params[:obj_type] #首先更新praise_tread 表 删除关注记录 #@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user") + @obj_id = params[:obj_id] + @obj_type = params[:obj_type] + if !params[:user_activity_id].nil? && !params[:type].nil? + @user_activity_id = params[:user_activity_id] + @type = params[:type] + @activity = true + end + @obj = find_object_by_type_and_id(@obj_type,@obj_id) @pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first + if @pt.nil? + respond_to do |format| + format.js + end + return + end @pt.delete if !@pt.nil? - #再更新praise_tread_cache表 使相应的记录减1 当为0时删除 @ptc = PraiseTreadCache.where("object_id=? and object_type=?",@obj_id,@obj_type.to_s).first @ptc.minus(1) if !@ptc.nil? @@ -55,12 +71,6 @@ class PraiseTreadController < ApplicationController end #@obj = User.find_by_id(@obj) - @obj = find_object_by_type_and_id(@obj_type,@obj_id) - if !params[:user_activity_id].nil? && !params[:type].nil? - @user_activity_id = params[:user_activity_id] - @type = params[:type] - @activity = true - end respond_to do |format| format.js end @@ -111,6 +121,12 @@ class PraiseTreadController < ApplicationController @obj = HomeworkCommon.find_by_id(id) when 'JournalsForMessage' @obj = JournalsForMessage.find_by_id(id) + when 'News' + @obj = News.find_by_id(id) + when 'Comment' + @obj = Comment.find_by_id(id) + when 'Journal' + @obj = Journal.find_by_id(id) end return @obj end diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb index 7926d2737..ddad08279 100644 --- a/app/views/organizations/_org_course_news.html.erb +++ b/app/views/organizations/_org_course_news.html.erb @@ -44,10 +44,16 @@ <% count=activity.comments.count %>
-
-
-
- 回复(<%= count %>) +
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> +
<%#= format_date(activity.updated_on) %>
<%if count>3 %> @@ -82,6 +88,13 @@ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + + <% if comment.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> +
<%= comment.comments.html_safe %>
diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index 32b717896..9c1863992 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -57,9 +57,17 @@
<% count = activity.journals.count %>
-
-
-
回复(<%= count %>)
+
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
<%#= format_date(activity.updated_on) %>
<% if count > 3 %>
@@ -93,6 +101,13 @@ <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> + + <% if reply.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> +
<% if reply.details.any? %> diff --git a/app/views/projects/_project_news.html.erb b/app/views/projects/_project_news.html.erb index 2d0c44151..1a28a164b 100644 --- a/app/views/projects/_project_news.html.erb +++ b/app/views/projects/_project_news.html.erb @@ -43,10 +43,16 @@
<% count=activity.comments.count %>
-
-
-
- 回复(<%= count %>) +
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> +
<%#= format_date(activity.updated_on) %>
<%if count>3 %> @@ -81,6 +87,13 @@ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + + <% if comment.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> +
<%= comment.comments.html_safe %>
diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index 7926d2737..ddad08279 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -44,10 +44,16 @@
<% count=activity.comments.count %>
-
-
-
- 回复(<%= count %>) +
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> +
<%#= format_date(activity.updated_on) %>
<%if count>3 %> @@ -82,6 +88,13 @@ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + + <% if comment.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> +
<%= comment.comments.html_safe %>
diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 099ec533f..954c24dac 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -69,9 +69,17 @@
<% count = activity.journals.count %>
-
-
-
回复(<%= count %>)
+
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
<%#= format_date(activity.updated_on) %>
<% if count > 3 %>
@@ -105,6 +113,13 @@ <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> + + <% if reply.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> +
<% if reply.details.any? %> diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb index bc7c401f2..dd55155d0 100644 --- a/app/views/users/_user_journalsformessage.html.erb +++ b/app/views/users/_user_journalsformessage.html.erb @@ -35,10 +35,16 @@
<% count=fetch_user_leaveWord_reply(activity).count %>
-
-
-
- 回复(<%= count %>) +
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> +
<%if count>3 %> @@ -68,6 +74,13 @@ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + + <% if comment.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> +
<%= comment.notes.html_safe %>