diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 88a524d1e..cad57b49f 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -100,7 +100,7 @@ class UsersController < ApplicationController
else
@user_activity_id = -1
end
- @is_in_course = params[:is_in_course]
+ @is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
end
respond_to do |format|
@@ -3236,6 +3236,38 @@ class UsersController < ApplicationController
end
end
+ def all_journals
+ if params[:type].present?
+ case params[:type]
+ when 'OrgDocumentComment'
+ obj = OrgDocumentComment.where('id = ?', params[:id].to_i).first
+ @journals = obj.children.reorder("created_at desc")
+ when 'Message'
+ obj = Message.where('id = ?', params[:id].to_i).first
+ @journals = obj.children.reorder("created_on desc")
+ when 'News'
+ obj = News.where('id = ?', params[:id].to_i).first
+ @journals = obj.comments.reorder("created_on desc")
+ when 'JournalsForMessage'
+ obj = JournalsForMessage.where('id = ?', params[:id].to_i).first
+ @journals = obj.children.reorder("created_on desc")
+ when 'Issue'
+ obj = Issue.where('id = ?', params[:id].to_i).first
+ @journals = obj.journals.reorder("created_on desc")
+ when 'BlogComment'
+ obj = BlogComment.where('id = ?', params[:id].to_i).first
+ @journals = obj.children.reorder("created_on desc")
+ when 'HomeworkCommon'
+ obj = HomeworkCommon.where('id = ?', params[:id].to_i).first
+ @journals = obj.journals_for_messages.reorder("created_on desc")
+ @is_in_course = params[:is_in_course].to_i if params[:is_in_course]
+ @course_activity = params[:course_activity].to_i if params[:course_activity]
+ @is_teacher = User.current.allowed_to?(:as_teacher,obj.course)
+ @user_activity_id = params[:user_activity_id].to_i if params[:user_activity_id]
+ end
+ end
+ end
+
private
def find_user
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index 05ae02fe2..8959e9c29 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -76,6 +76,18 @@ class BlogComment < ActiveRecord::Base
def project
end
+ def creator_user
+ self.author
+ end
+
+ def created_time
+ self.created_at
+ end
+
+ def content_detail
+ self.content
+ end
+
#博客回复微信模板消息
# def blog_wechat_message
# ws = WechatService.new
diff --git a/app/models/comment.rb b/app/models/comment.rb
index edb5e472f..80b52a8f4 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -104,4 +104,16 @@ class Comment < ActiveRecord::Base
end
end
+ def creator_user
+ self.author
+ end
+
+ def created_time
+ self.created_on
+ end
+
+ def content_detail
+ self.comments
+ end
+
end
diff --git a/app/models/journal.rb b/app/models/journal.rb
index bea273a41..0f88fcb7f 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -137,6 +137,18 @@ class Journal < ActiveRecord::Base
end
##
+ def creator_user
+ self.user
+ end
+
+ def created_time
+ self.created_on
+ end
+
+ def content_detail
+ self.notes
+ end
+
private
def split_private_notes
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index d8819515c..68cb9da15 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -329,4 +329,16 @@ class JournalsForMessage < ActiveRecord::Base
down_course_score_num(self.jour.course_id, self.user_id, "HomeworkCommon")
end
end
+
+ def creator_user
+ self.user
+ end
+
+ def created_time
+ self.created_on
+ end
+
+ def content_detail
+ self.notes
+ end
end
diff --git a/app/models/message.rb b/app/models/message.rb
index 393fd3a60..14add0d02 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -221,6 +221,18 @@ class Message < ActiveRecord::Base
update_org_activity(self.class, self.id)
end
+ def creator_user
+ self.author
+ end
+
+ def created_time
+ self.created_on
+ end
+
+ def content_detail
+ self.content
+ end
+
private
def add_author_as_watcher
diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb
index dd070c825..dd7734a54 100644
--- a/app/models/org_document_comment.rb
+++ b/app/models/org_document_comment.rb
@@ -35,4 +35,15 @@ class OrgDocumentComment < ActiveRecord::Base
end
+ def creator_user
+ self.creator
+ end
+
+ def created_time
+ self.created_at
+ end
+
+ def content_detail
+ self.content
+ end
end
diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb
index 763748ad7..16d151d83 100644
--- a/app/views/courses/_course_activity.html.erb
+++ b/app/views/courses/_course_activity.html.erb
@@ -52,23 +52,6 @@
<% course_activities.includes(:course_act).each do |activity| if course_activities %>
- <% replies_all_i=replies_all_i+1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_url_in_org(reply.author_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
-
-
-
- <%= reply.content.html_safe %>
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/organizations/_org_subfield_news.html.erb b/app/views/organizations/_org_subfield_news.html.erb
index 662a965e9..a822b4a0d 100644
--- a/app/views/organizations/_org_subfield_news.html.erb
+++ b/app/views/organizations/_org_subfield_news.html.erb
@@ -70,48 +70,17 @@
<%#= format_date(activity.updated_on) %>
<%if count>3 %>
<% end %>
- <% replies_all_i = 0 %>
+ <% comments = activity.comments.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% activity.comments.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_url_in_org(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb
index 3042ca9ae..f9ca06d90 100644
--- a/app/views/organizations/_show_org_document.html.erb
+++ b/app/views/organizations/_show_org_document.html.erb
@@ -6,7 +6,7 @@
- <%= link_to User.find(document.creator_id), user_url_in_org(document.creator.id), :class => "newsBlue mr15" %>
+ <%= link_to document.creator.show_name, user_url_in_org(document.creator.id), :class => "newsBlue mr15" %>
TO <%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %>
|
<%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %>
@@ -61,7 +61,7 @@
<% end %>
- <% comments_for_doc = document.children.reorder("created_at desc") %>
+ <% comments_for_doc = document.children.reorder("created_at desc").limit(3) %>
<% count = document.children.count() %>
@@ -74,41 +74,14 @@
<% if count > 3 %>
<% end %>
-
- <% reply_id = 0 %>
- <% comments_for_doc.each do |comment| %>
-
- <% reply_id += 1 %>
- -
-
<%= link_to image_tag(url_to_avatar(User.find(comment.creator_id)), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_id) %>
-
-
- <%= link_to User.find(comment.creator_id), user_url_in_org(comment.creator_id), :class => "newsBlue mr10 f14" %>
- <%= format_activity_day(comment.created_at) %> <%= format_time(comment.created_at, false) %>
-
-
- <% unless comment.content.blank? %>
-
- <% end %>
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments_for_doc}%>
@@ -134,22 +107,6 @@
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_all_replies.html.erb b/app/views/users/_all_replies.html.erb
new file mode 100644
index 000000000..15c8944fd
--- /dev/null
+++ b/app/views/users/_all_replies.html.erb
@@ -0,0 +1,39 @@
+
+ <% comments.each do |comment| %>
+
+ -
+
+ <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
+
+
+
+ <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %>
+ <%= format_activity_day(comment.created_time) %> <%= format_time(comment.created_time, false) %>
+
+
+ <% unless comment.content_detail.blank? %>
+
+ <% end %>
+
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_comment_reply.html.erb b/app/views/users/_comment_reply.html.erb
index 895eda8a9..77dcea1f2 100644
--- a/app/views/users/_comment_reply.html.erb
+++ b/app/views/users/_comment_reply.html.erb
@@ -4,24 +4,5 @@
<%=render :partial => 'users/comment_reply', :locals => {:comment => comment.parent} %>
<% end %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "content-username" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "content-username" %>
- <% end %>
-
<%= time_from_now(comment.created_on) %>
-
<%= comment.notes.html_safe %>
-
-
+ <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => comment} %>
\ No newline at end of file
diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb
index e694f471e..701f81da1 100644
--- a/app/views/users/_course_homework.html.erb
+++ b/app/views/users/_course_homework.html.erb
@@ -302,91 +302,17 @@
<%if count>3 %>
<% end %>
- <% replies_all_i = 0 %>
+ <% comments = activity.journals_for_messages.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% activity.journals_for_messages.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= time_from_now(comment.created_on) %>
-
- <% unless comment.m_parent_id.nil? %>
- <% parents_rely = [] %>
- <% parents_rely = get_reply_parents parents_rely, comment %>
- <% length = parents_rely.length %>
-
- <% end %>
-
-
-
-
-
-
- <%= link_to(
- l(:button_reply),
- {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :is_in_course => -1, :user_activity_id => user_activity_id, :course_activity=>course_activity},
- :remote => true,
- :method => 'get',
- :title => l(:button_reply)) %>
-
-
-
- <% if User.current.admin? ||is_teacher || comment.user == User.current%>
- <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => -1, :user_activity_id => user_activity_id, :course_activity=>course_activity},
- :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %>
- <% end %>
-
-
-
-
-
-
-
-
- <% end %>
-
+ <%=render :partial => 'users/homework_replies', :locals => {:comments => comments, :is_in_course => -1,:course_activity=>course_activity, :is_teacher => is_teacher, :user_activity_id => user_activity_id} %>
<% end %>
diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb
index a76081859..e04dd3006 100644
--- a/app/views/users/_course_journalsformessage.html.erb
+++ b/app/views/users/_course_journalsformessage.html.erb
@@ -43,50 +43,17 @@
<%if count>3 %>
<% end %>
- <% replies_all_i = 0 %>
+ <% comments = activity.children.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% fetch_user_leaveWord_reply(activity).each do |comment| unless fetch_user_leaveWord_reply(activity).nil? %>
-
- <% replies_all_i = replies_all_i + 1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb
index c0e667396..76971e240 100644
--- a/app/views/users/_course_message.html.erb
+++ b/app/views/users/_course_message.html.erb
@@ -97,7 +97,7 @@
<%#=format_date(activity.updated_on)%>
<%if count > 3 %>
@@ -105,43 +105,10 @@
<% activity= activity.parent ? activity.parent : activity%>
- <% replies_all_i = 0 %>
+ <% comments = activity.children.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% activity.children.includes(:author).reorder("created_on desc").each do |reply|%>
-
- <% replies_all_i=replies_all_i+1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
-
-
-
-
- <%= reply.content.html_safe %>
-
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb
index b89873b43..5ffa78158 100644
--- a/app/views/users/_course_news.html.erb
+++ b/app/views/users/_course_news.html.erb
@@ -75,48 +75,17 @@
<%#= format_date(activity.updated_on) %>
<%if count>3 %>
<% end %>
- <% replies_all_i = 0 %>
+ <% comments = activity.comments.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% activity.comments.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_homework_replies.html.erb b/app/views/users/_homework_replies.html.erb
new file mode 100644
index 000000000..de6e96ae3
--- /dev/null
+++ b/app/views/users/_homework_replies.html.erb
@@ -0,0 +1,78 @@
+
+ <% comments.reorder("created_on desc").each do |comment| %>
+
+ -
+
+ <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:user).try(:realname) == ' ' %>
+ <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= time_from_now(comment.created_on) %>
+
+ <% unless comment.m_parent_id.nil? %>
+ <% parents_rely = [] %>
+ <% parents_rely = get_reply_parents parents_rely, comment %>
+ <% length = parents_rely.length %>
+
+ <% end %>
+
+
+
+
+
+
+ <%= link_to(
+ l(:button_reply),
+ {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :is_in_course => is_in_course, :user_activity_id => user_activity_id, :course_activity => course_activity},
+ :remote => true,
+ :method => 'get',
+ :title => l(:button_reply)) %>
+
+
+
+ <% if User.current.admin? ||is_teacher || comment.user == User.current%>
+ <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => is_in_course, :course_activity => course_activity},
+ :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %>
+ <% end %>
+
+
+
+
+
+
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_project_issue_reply.html.erb b/app/views/users/_project_issue_reply.html.erb
index 2b43d8acf..1f4c4b44b 100644
--- a/app/views/users/_project_issue_reply.html.erb
+++ b/app/views/users/_project_issue_reply.html.erb
@@ -10,54 +10,17 @@
<%#= format_date(activity.updated_on) %>
<% if count > 3 %>
<% end %>
- <% replies_all_i = 0 %>
+ <% comments = activity.journals.includes(:user, :details).reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% activity.journals.includes(:user, :details).reorder("created_on desc").each do |reply| %>
-
- <% replies_all_i=replies_all_i + 1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:user).try(:realname) == ' ' %>
- <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
-
-
-
- <% if reply.details.any? %>
- <% details_to_strings(reply.details).each do |string| %>
-
<%= string %>
- <% end %>
- <% end %>
-
<%= reply.notes.html_safe %>
-
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb
index b3c2fea59..f82dc35e7 100644
--- a/app/views/users/_project_message.html.erb
+++ b/app/views/users/_project_message.html.erb
@@ -95,46 +95,15 @@
<%#=format_date(activity.updated_on)%>
<%if count>3 %>
-
+
<% end %>
<% activity= activity.parent_id.nil? ? activity : activity.parent %>
- <% replies_all_i = 0 %>
+ <% comments = activity.children.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% activity.children.includes(:author).reorder("created_on desc").each do |reply| %>
-
- <% replies_all_i=replies_all_i+1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
-
-
-
- <%= reply.content.html_safe %>
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb
index b354bc668..43b22b193 100644
--- a/app/views/users/_project_news.html.erb
+++ b/app/views/users/_project_news.html.erb
@@ -72,48 +72,17 @@
<%#= format_date(activity.updated_on) %>
<%if count>3 %>
<% end %>
- <% replies_all_i = 0 %>
+ <% comments = activity.comments.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% activity.comments.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb
index 432074191..3b327c080 100644
--- a/app/views/users/_user_activities.html.erb
+++ b/app/views/users/_user_activities.html.erb
@@ -29,23 +29,6 @@
<% user_activities.each do |user_activity|
if user_activities %>
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb
index a01418d2f..97eeec89f 100644
--- a/app/views/users/_user_homework_detail.html.erb
+++ b/app/views/users/_user_homework_detail.html.erb
@@ -312,95 +312,17 @@
<%if count>3 %>
<% end %>
- <% replies_all_i = 0 %>
+ <% comments = homework_common.journals_for_messages.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% homework_common.journals_for_messages.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= time_from_now(comment.created_on) %>
-
- <% unless comment.m_parent_id.nil? %>
- <% parents_rely = [] %>
- <% parents_rely = get_reply_parents parents_rely, comment %>
- <% length = parents_rely.length %>
-
- <% end %>
-
-
-
-
-
-
- <%= link_to(
- l(:button_reply),
- {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :is_in_course => is_in_course, :course_activity => -1},
- :remote => true,
- :method => 'get',
- :title => l(:button_reply)) %>
-
-
-
- <% if User.current.admin? ||is_teacher || comment.user == User.current%>
- <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => is_in_course, :course_activity => -1},
- :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %>
- <% end %>
-
-
-
-
-
-
-
-
- <% end %>
-
+ <%=render :partial => 'users/homework_replies', :locals => {:comments => comments, :is_in_course => is_in_course, :course_activity=> -1, :is_teacher => is_teacher, :user_activity_id => -1} %>
<% end %>
diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb
index 6967bb398..e7f42c661 100644
--- a/app/views/users/_user_journalsformessage.html.erb
+++ b/app/views/users/_user_journalsformessage.html.erb
@@ -70,57 +70,17 @@
<%if count>3 %>
<% end %>
- <% replies_all_i = 0 %>
+ <% comments = activity.children.reorder("created_on desc").limit(3) %>
<% if count > 0 %>
-
- <% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
- -
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
-
- <% end %>
-
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
<% end %>
diff --git a/app/views/users/_user_jours_list.html.erb b/app/views/users/_user_jours_list.html.erb
index 94d2998ae..afd498d06 100644
--- a/app/views/users/_user_jours_list.html.erb
+++ b/app/views/users/_user_jours_list.html.erb
@@ -7,22 +7,6 @@
<% jours.each do |jour|%>
<% unless jour.private == 1 && (!User.current || (User.current && jour.jour_id != User.current.id && jour.user_id != User.current.id)) %>