From b77779ca55f9ae4ac5b002461c3ad7f08baec7c1 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Jul 2016 17:23:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=9A=84=E4=BA=8C=E7=BA=A7?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E5=92=8C=E7=BB=84=E7=BB=87=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E7=9A=84=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org_document_comments_controller.rb | 38 ++--- app/controllers/users_controller.rb | 11 +- app/helpers/application_helper.rb | 9 +- .../messages/_org_subfield_show.html.erb | 132 ++++++++++-------- .../_simple_ke_reply_form.html.erb | 3 +- .../org_document_comments/destroy.js.erb | 5 +- app/views/org_document_comments/quote.js.erb | 2 - app/views/org_document_comments/reply.js.erb | 5 +- app/views/org_document_comments/show.html.erb | 70 ++++++---- .../_org_subfield_message.html.erb | 16 +-- .../organizations/_show_org_document.html.erb | 18 ++- .../users/_comment_reply_detail.html.erb | 2 +- app/views/users/_course_message.html.erb | 2 - .../users/_org_document_replies.html.erb | 60 ++++++++ app/views/users/_reply_to.html.erb | 14 +- app/views/users/all_journals.js.erb | 2 + 16 files changed, 245 insertions(+), 144 deletions(-) create mode 100644 app/views/users/_org_document_replies.html.erb diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 264c1fc9f..924be596e 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -123,10 +123,14 @@ class OrgDocumentCommentsController < ApplicationController def destroy @org_document_comment = OrgDocumentComment.find(params[:id]) @org_sub_id = @org_document_comment.org_subfield_id - org = @org_document_comment.organization + org = @org_document_comment.root.organization if @org_document_comment.id == org.home_id org.update_attributes(:home_id => nil) end + if params[:user_activity_id] + @act = OrgActivity.find(params[:user_activity_id]) + @document = @org_document_comment.root + end if @org_document_comment.destroy end respond_to do |format| @@ -145,48 +149,26 @@ class OrgDocumentCommentsController < ApplicationController end def quote @org_comment = OrgDocumentComment.find(params[:id]) - @subject = @org_comment.content - @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') - - @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> " @temp = OrgDocumentComment.new - #@course_id = params[:course_id] - @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}
#{@org_comment.content.html_safe}
".html_safe respond_to do | format| format.js end end def reply - @document = OrgDocumentComment.find(params[:id]).root - @quote = params[:quote][:quote] + @document = OrgDocumentComment.find(params[:id]) @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id]) - # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 - # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 @org_document.title = params[:org_document_comment][:title] @org_document.content = params[:org_document_comment][:content] - @org_document.content = @quote + @org_document.content - #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @document.children << @org_document - # @user_activity_id = params[:user_activity_id] - # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first - # if user_activity - # user_activity.updated_at = Time.now - # user_activity.save - # end - # attachments = Attachment.attach_files(@org_document, params[:attachments]) - # render_attachment_warning_if_needed(@org_document) - #@article.save - # redirect_to user_blogs_path(:user_id=>params[:user_id]) + @document = @document.root + @user_activity_id = params[:user_activity_id] + @act = OrgActivity.find(@user_activity_id) if @user_activity_id respond_to do |format| format.html { - # if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 - # redirect_to syllabus_course_path(:id=>params[:course_id]) - # else redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id) - # end - } format.js end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e7c75eb13..335604205 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -128,6 +128,11 @@ class UsersController < ApplicationController @activity_id = params[:activity_id] @homepage = params[:homepage] @type = 'BlogComment' + when 'OrgDocumentComment' + @reply = OrgDocumentComment.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'OrgDocumentComment' end respond_to do |format| format.js @@ -3286,7 +3291,10 @@ class UsersController < ApplicationController case params[:type] when 'OrgDocumentComment' obj = OrgDocumentComment.where('id = ?', params[:id].to_i).first - @journals = obj.children.reorder("created_at desc") + @user_activity_id = params[:div_id].to_i if params[:div_id] + @type = 'OrgDocumentComment' + comments = [] + @journals = get_all_children(comments, obj) when 'Message' obj = Message.where('id = ?', params[:id].to_i).first @type = 'Message' @@ -3315,6 +3323,7 @@ class UsersController < ApplicationController obj = BlogComment.where('id = ?', params[:id].to_i).first @user_activity_id = params[:div_id].to_i if params[:div_id] @homepage = params[:homepage].to_i + @type = 'BlogComment' comments = [] @journals = get_all_children(comments, obj) when 'HomeworkCommon' diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3d8d970b5..1306d5625 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3141,13 +3141,18 @@ end #获取所有子节点 def get_all_children result, jour - if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) || (jour.kind_of? BlogComment) + if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) || (jour.kind_of? BlogComment) || (jour.kind_of? OrgDocumentComment) jour.children.each do |jour_child| result << jour_child get_all_children result, jour_child end end - result.sort! { |a,b| b.created_on <=> a.created_on } + if jour.respond_to?(:created_on) + result.sort! { |a,b| b.created_on <=> a.created_on } + elsif jour.respond_to?(:created_at) + result.sort! { |a,b| b.created_at <=> a.created_at } + end + result end #将有置顶属性的提到数组前面 diff --git a/app/views/messages/_org_subfield_show.html.erb b/app/views/messages/_org_subfield_show.html.erb index e5455bc85..39fceb456 100644 --- a/app/views/messages/_org_subfield_show.html.erb +++ b/app/views/messages/_org_subfield_show.html.erb @@ -4,22 +4,22 @@
- <%= link_to image_tag(url_to_avatar(@topic.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@topic.author) %> + <%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50, :alt => '图像'), user_path(@topic.author) %>
<% if User.current.logged? %> -