From 196c92f9c4c0c0c514010e566886a8a13421e4ea Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 7 Jun 2016 16:02:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=9B=9E=E5=A4=8D=E6=9C=80?= =?UTF-8?q?=E5=A4=9A=E5=8F=AA=E5=8A=A0=E8=B5=9E=E4=B8=89=E6=9D=A1=EF=BC=8C?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=B1=95=E5=BC=80=E6=9B=B4=E5=A4=9A=E6=97=B6?= =?UTF-8?q?=E6=89=8D=E5=8A=A0=E8=BD=BD=E4=BD=99=E4=B8=8B=E7=9A=84=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 34 +++++++- app/models/blog_comment.rb | 12 +++ app/models/comment.rb | 12 +++ app/models/journal.rb | 12 +++ app/models/journals_for_message.rb | 12 +++ app/models/message.rb | 12 +++ app/models/org_document_comment.rb | 11 +++ app/views/courses/_course_activity.html.erb | 17 ---- app/views/news/_project_news_detail.html.erb | 17 ---- .../organizations/_org_activities.html.erb | 20 ++--- .../_org_subfield_message.html.erb | 37 +------- .../organizations/_org_subfield_news.html.erb | 37 +------- .../organizations/_show_org_document.html.erb | 51 +---------- .../projects/_project_activities.html.erb | 17 ---- app/views/projects/_project_news.html.erb | 37 +------- app/views/users/_all_replies.html.erb | 39 +++++++++ app/views/users/_comment_reply.html.erb | 21 +---- app/views/users/_course_homework.html.erb | 80 +----------------- .../users/_course_journalsformessage.html.erb | 39 +-------- app/views/users/_course_message.html.erb | 39 +-------- app/views/users/_course_news.html.erb | 37 +------- app/views/users/_homework_replies.html.erb | 78 +++++++++++++++++ app/views/users/_project_issue_reply.html.erb | 43 +--------- app/views/users/_project_message.html.erb | 37 +------- app/views/users/_project_news.html.erb | 37 +------- app/views/users/_user_activities.html.erb | 17 ---- app/views/users/_user_blog.html.erb | 37 +------- .../users/_user_homework_detail.html.erb | 84 +------------------ .../users/_user_journalsformessage.html.erb | 46 +--------- app/views/users/_user_jours_list.html.erb | 16 ---- app/views/users/all_journals.js.erb | 5 ++ config/routes.rb | 1 + public/javascripts/application.js | 81 ++++++++++++++---- 33 files changed, 347 insertions(+), 728 deletions(-) create mode 100644 app/views/users/_all_replies.html.erb create mode 100644 app/views/users/_homework_replies.html.erb create mode 100644 app/views/users/all_journals.js.erb 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 %>
    - + <%= 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 %>
    - + <%= 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) %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - -
    -
    - <%= comment.comments.html_safe %>
    -
    -
    -
  • - <% 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 @@ + \ 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 %>
    - + <%=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 %>
    - + <%= 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 %>
    - + <%= 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 %>
    - + <%= 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 @@ + \ 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 %>
    - + <%= 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 %>
    - + <%= 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 %>
    - + <%= 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) %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - -
    -
    - <%= comment.content.html_safe %>
    -
    -
    -
  • - <% 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 %>
    - + <%=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 %>
    - + <%= 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)) %>