From 955c258856844c0858be9508de76677d71e82b99 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Jul 2016 10:35:52 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E7=9A=84=E5=BC=B9=E6=A1=86=E4=B8=AD=E2=80=9C=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E2=80=9D=E4=B8=8B=E6=8B=89=E6=A1=86=E4=B8=AD?= =?UTF-8?q?=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=BD=93=E5=89=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E6=89=80=E6=9C=89=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_copy_course.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index cc7f2fb53..d7a9fa4cd 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -53,7 +53,7 @@
  • - <%= select_tag :syllabus_id,options_for_select(syllabus_option,@course.syllabus_id), {:id=>"new_syllabus_id", :class=>"syllabus_input"} %> + <%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"new_syllabus_id", :class=>"syllabus_input"} %>
  • From f0e456729e1f6ab9510494ffd365c7d3e4e7cd45 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Jul 2016 16:21:30 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=89=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E4=B8=AD=E7=9A=84html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 8 ++++++++ app/views/layouts/_show_messages_list.html.erb | 16 ++++++++-------- .../users/_join_course_course_message.html.erb | 2 +- app/views/users/_user_message_course.html.erb | 10 +++++----- app/views/users/_user_message_forum.html.erb | 2 +- app/views/users/_user_message_system.html.erb | 2 +- .../users/_user_message_userfeedaback.html.erb | 2 +- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 23fd401fd..3a28e4b72 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3296,6 +3296,14 @@ def strip_html(text,len=0,endss="...") return ss end +def message_content content + content = (strip_html content).strip + if content.gsub(" ", "") == "" + content = "[非文本消息]" + end + content +end + def get_hw_index(hw,is_teacher) if is_teacher homeworks = hw.course.homework_commons.order("created_at asc") diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb index ba31c4379..0829b9c42 100644 --- a/app/views/layouts/_show_messages_list.html.erb +++ b/app/views/layouts/_show_messages_list.html.erb @@ -5,7 +5,7 @@
      <% messages.each do |ma| %> <% if ma.class == SystemMessage %> -
    • Trustie平台 发布新消息:<%= ma.subject.blank? ? (ma.content.nil? ? ma.description.html_safe : ma.content.html_safe) : ma.subject%>
    • +
    • Trustie平台 发布新消息:<%= ma.subject.blank? ? (ma.content.nil? ? message_content(ma.description) : message_content(ma.content)) : ma.subject%>
    • <% elsif ma.class == CourseMessage %> <% if ma.course_message_type == "News" %>
    • <%=ma.course_message.author.show_name %> 发布了通知:<%= ma.course_message.title%>
    • @@ -50,18 +50,18 @@ <% elsif ma.course_message_type == "Poll" %>
    • "><%=ma.course_message.user.show_name %> 发布了问卷:<%= ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name%>
    • <% elsif ma.course_message_type == "Message" %> - <% content = ma.course_message.parent_id.nil? ? ma.course_message.subject : ma.course_message.content.html_safe %> + <% content = ma.course_message.parent_id.nil? ? ma.course_message.subject : message_content(ma.course_message.content) %> <% href = board_message_path(ma.course_message.board_id, ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id) %>
    • <%= content%>"><%=ma.course_message.author.show_name %> <%= ma.course_message.parent_id.nil? ? "发布了班级帖子:" : "评论了班级帖子:" %><%= content%>
    • <% elsif ma.course_message_type == "StudentWorksScore" %> -
    • <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %><%= ma.content.html_safe if !ma.content.nil?%>"><%=ma.course_message.reviewer_role == 3 ? '匿名用户' : ma.course_message.user.show_name+"老师" %> <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %><%= ma.content.html_safe if !ma.content.nil?%>
    • +
    • <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %><%= message_content(ma.content) if !ma.content.nil?%>"><%=ma.course_message.reviewer_role == 3 ? '匿名用户' : ma.course_message.user.show_name+"老师" %> <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %><%= message_content(ma.content) if !ma.content.nil?%>
    • <% elsif ma.course_message_type == "JournalsForMessage" %> <% if ma.course_message.jour_type == 'Course' %> -
    • <%=ma.course_message.user.show_name %> 在班级中留言了:<%= ma.course_message.notes.html_safe%>
    • +
    • <%=ma.course_message.user.show_name %> 在班级中留言了:<%= message_content(ma.course_message.notes)%>
    • <% elsif ma.course_message.jour_type == 'HomeworkCommon' %> -
    • <%=ma.course_message.user.show_name %> <%=ma.course_message.m_parent_id.nil? ? '回复了您的作业:' : '在作业中回复了您:' %><%= ma.course_message.notes.html_safe%>
    • +
    • <%=ma.course_message.user.show_name %> <%=ma.course_message.m_parent_id.nil? ? '回复了您的作业:' : '在作业中回复了您:' %><%= message_content(ma.course_message.notes)%>
    • <% else %> -
    • <%=ma.course_message.user.show_name %><%=ma.course_message.user.allowed_to?(:as_teacher, ma.course) ? '老师' : '同学' %> 回复了作品评论:<%= ma.course_message.notes%>
    • +
    • <%=ma.course_message.user.show_name %><%=ma.course_message.user.allowed_to?(:as_teacher, ma.course) ? '老师' : '同学' %> 回复了作品评论:<%= message_content(ma.course_message.notes)%>
    • <% end %> <% elsif ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? && !User.current.allowed_to?(:as_teacher, ma.course_message.homework_common.course) %>
    • <%=ma.course_message.homework_common.user.show_name %>老师 发布的作业:<%=ma.course_message.homework_common.name %>,由于迟交作业,您及您的作品都不能参与该作业的匿评
    • @@ -112,11 +112,11 @@ <% end %> <% elsif ma.class == MemoMessage %> <% if ma.memo_type == "Memo" %> -
    • <%= ma.memo.parent_id.nil? ? ma.memo.subject : ma.memo.content.html_safe%>"><%=ma.memo.author.show_name %> <%= ma.memo.parent_id.nil? ? "在贴吧发布帖子:" : "回复了贴吧帖子:" %><%= ma.memo.parent_id.nil? ? ma.memo.subject : ma.memo.content.html_safe%>
    • +
    • <%= ma.memo.parent_id.nil? ? ma.memo.subject : message_content(ma.memo.content)%>"><%=ma.memo.author.show_name %> <%= ma.memo.parent_id.nil? ? "在贴吧发布帖子:" : "回复了贴吧帖子:" %><%= ma.memo.parent_id.nil? ? ma.memo.subject : message_content(ma.memo.content)%>
    • <% end %> <% elsif ma.class == UserFeedbackMessage %> <% if ma.journals_for_message_type == "JournalsForMessage" %> -
    • <%= ma.journals_for_message.notes.gsub("

      ","").gsub("

      ","").gsub("
      ","").html_safe%>"><%=ma.journals_for_message.user.show_name %> <%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %><%= ma.journals_for_message.notes.gsub("

      ","").gsub("

      ","").gsub("
      ","").html_safe%>
    • +
    • <%= message_content(ma.journals_for_message.notes)%>"><%=ma.journals_for_message.user.show_name %> <%= ma.journals_for_message.reply_id == 0 || ma.journals_for_message.reply_id.nil? ? "给你留言了:" : "回复了你的留言:" %><%= message_content(ma.journals_for_message.notes)%>
    • <% end %> <% elsif ma.class == OrgMessage %> <% if ma.message_type == 'ApplySubdomain' %> diff --git a/app/views/users/_join_course_course_message.html.erb b/app/views/users/_join_course_course_message.html.erb index 01ebb5cf9..d0718c11e 100644 --- a/app/views/users/_join_course_course_message.html.erb +++ b/app/views/users/_join_course_course_message.html.erb @@ -18,7 +18,7 @@

      真实姓名:<%= User.find(ma.course_message_id).realname %>

      申请课程:<%= Course.find(ma.course_id).name%>

      课程描述:
      -
      <%= Course.find(ma.course_id).description.html_safe %>
      +
      <%= Course.find(ma.course_id).description.html_safe if Course.find(ma.course_id).description %>

      申请职位:<%= ma.content == '9' ? "教师" : "教辅"%>

    • diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index f48ce7010..065cb0b27 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -309,7 +309,7 @@ <% else %>
    • - <%= link_to ma.course_message.content.html_safe, board_message_path(ma.course_message.board_id, ma.course_message.parent_id), + <%= link_to message_content(ma.course_message.content), board_message_path(ma.course_message.board_id, ma.course_message.parent_id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -348,7 +348,7 @@
    • <% unless ma.content.nil? %> - <%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id), + <%= link_to message_content(ma.content), student_work_index_path(:homework => ma.course_message.student_work.homework_common_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -387,7 +387,7 @@ ">在班级中留言了:
    • - <%= link_to ma.course_message.notes.html_safe, course_feedback_path(:id => ma.course_id), + <%= link_to message_content(ma.course_message.notes), course_feedback_path(:id => ma.course_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -414,7 +414,7 @@
    • - <%= link_to ma.course_message.notes.html_safe, homework_common_index_url_in_org( ma.course_id), + <%= link_to message_content(ma.course_message.notes), homework_common_index_url_in_org( ma.course_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -437,7 +437,7 @@ ">回复了作品评论:
    • - <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> + <%= link_to message_content(ma.course_message.notes), student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> diff --git a/app/views/users/_user_message_forum.html.erb b/app/views/users/_user_message_forum.html.erb index e0111276a..4757aa401 100644 --- a/app/views/users/_user_message_forum.html.erb +++ b/app/views/users/_user_message_forum.html.erb @@ -17,7 +17,7 @@
    • <% else %>
    • - <%= link_to ma.memo.content.html_safe, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> + <%= link_to message_content(ma.memo.content), forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> diff --git a/app/views/users/_user_message_system.html.erb b/app/views/users/_user_message_system.html.erb index a7e48f456..13967dce1 100644 --- a/app/views/users/_user_message_system.html.erb +++ b/app/views/users/_user_message_system.html.erb @@ -10,7 +10,7 @@ 【系统消息】
    • - <%= link_to ma.subject.blank? ? (ma.content.nil? ? ma.description.html_safe : ma.content.html_safe) : ma.subject, user_system_messages_path(User.current), + <%= link_to ma.subject.blank? ? (ma.content.nil? ? message_content(ma.description) : message_content(ma.content)) : ma.subject, user_system_messages_path(User.current), :id => "content_link_#{ma.id}", :target => '_blank' %> diff --git a/app/views/users/_user_message_userfeedaback.html.erb b/app/views/users/_user_message_userfeedaback.html.erb index 3af623813..1c33d9de4 100644 --- a/app/views/users/_user_message_userfeedaback.html.erb +++ b/app/views/users/_user_message_userfeedaback.html.erb @@ -9,7 +9,7 @@ "><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %>
    • - <%= link_to ma.journals_for_message.notes.gsub("

      ","").gsub("

      ","").gsub("
      ","").html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank'%> + <%= link_to message_content(ma.journals_for_message.notes), feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank'%>
    • From 16cf8a56a1fa0dfe1bd55aee75afdd385eeba826 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 13 Jul 2016 09:34:36 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=92=8C?= =?UTF-8?q?=E8=80=81=E5=B8=88=E5=8F=AF=E7=9C=8B=E5=88=B0=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E6=89=80=E6=9C=89=E7=8F=AD=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 2 +- app/controllers/syllabuses_controller.rb | 6 +++++- app/controllers/users_controller.rb | 9 +++++++-- app/views/layouts/base_syllabus.html.erb | 9 +++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 52e1f5fd0..36a5d9d4f 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -82,7 +82,7 @@ class AdminController < ApplicationController syllabus.update_attributes(:title => params[:title], :eng_name => params[:eng_name], :user_id => @user.id) syllabus.description = Message.where("id = 19412").first.nil? ? nil : Message.where("id = 19412").first.content if syllabus.save - course.update_attribute('syllabus_id', syllabus.id) + course.update_column('syllabus_id', syllabus.id) @flag = params[:flag].to_i @course = course respond_to do |format| diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index 8d7195f38..291e6ca30 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -109,7 +109,11 @@ class SyllabusesController < ApplicationController sort_name = "updated_on" sort_type = @c_sort == 1 ? "asc" : "desc" - @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") + if User.current == @syllabus.user || User.current.admin? + @courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") + else + @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") + end #根据 作业+资源数排序 if @order.to_i == 2 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 83a794cd9..373b4f514 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1410,8 +1410,13 @@ class UsersController < ApplicationController @all_count = @user.courses.visible.where("is_delete =?", 0).count elsif @type == 'Syllabus' @syllabus = Syllabus.where("id = #{params[:syllabus]}").first - @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) - @all_count = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).count + if User.current == @syllabus.user || User.current.admin? + all_courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc") + else + all_courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc") + end + @courses = all_courses.limit(5).offset(@page * 5) + @all_count = all_courses.count end end diff --git a/app/views/layouts/base_syllabus.html.erb b/app/views/layouts/base_syllabus.html.erb index 5aa23b3c5..b0ecea006 100644 --- a/app/views/layouts/base_syllabus.html.erb +++ b/app/views/layouts/base_syllabus.html.erb @@ -75,8 +75,13 @@ <% end%> <% end%> - <% courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %> - <% all_count = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).count%> + <% if User.current == @syllabus.user || User.current.admin? + all_courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc") + else + all_courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc") + end %> + <% courses = all_courses.limit(5) %> + <% all_count = all_courses.count%>
        From 9bf853d2bbcb6d781441bde7fa897b2d6e35b0de Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 13 Jul 2016 09:49:24 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=8F=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E5=90=8D=E7=A7=B0=E5=92=8C?= =?UTF-8?q?=E8=8B=B1=E6=96=87=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_syllabus_eng_name.html.erb | 2 +- app/views/layouts/_syllabus_title.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_syllabus_eng_name.html.erb b/app/views/layouts/_syllabus_eng_name.html.erb index ed8035736..72af30927 100644 --- a/app/views/layouts/_syllabus_eng_name.html.erb +++ b/app/views/layouts/_syllabus_eng_name.html.erb @@ -3,6 +3,6 @@ <% else%> 课程英文名称 <% end %> -<% if User.current == syllabus.user %> +<% if User.current == syllabus.user || User.current.admin? %> <%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);",:id => "syllabus_edit_ng_name_png", :class => "none", :onclick => "show_edit_eng_name();"%> <% end %> \ No newline at end of file diff --git a/app/views/layouts/_syllabus_title.html.erb b/app/views/layouts/_syllabus_title.html.erb index 5180da82d..51737fe4e 100644 --- a/app/views/layouts/_syllabus_title.html.erb +++ b/app/views/layouts/_syllabus_title.html.erb @@ -1,5 +1,5 @@ <%=@syllabus.title %> -<% if User.current == syllabus.user %> +<% if User.current == syllabus.user || User.current.admin? %> <%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);",:id => "syllabus_edit_title_png", :class => "none", :onclick => "show_edit_title();"%> <% end %> \ No newline at end of file From ded8f48d34406bdf3fbc80a560bd9b4d8da10abf Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 13 Jul 2016 15:20:39 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E7=9A=84=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/at_controller.rb | 6 +- app/controllers/blog_comments_controller.rb | 11 +++- app/controllers/users_controller.rb | 5 ++ app/helpers/application_helper.rb | 2 +- app/views/blog_comments/reply.js.erb | 2 +- .../users/_blog_comments_replies.html.erb | 59 +++++++++++++++++++ app/views/users/_reply_to.html.erb | 13 ++++ app/views/users/_user_blog.html.erb | 5 +- 8 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 app/views/users/_blog_comments_replies.html.erb diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb index 5b29565ad..69c33f90e 100644 --- a/app/controllers/at_controller.rb +++ b/app/controllers/at_controller.rb @@ -47,6 +47,8 @@ class AtController < ApplicationController find_journals_for_message(id) when 'Principal' find_principal(id) + when 'BlogComment' + find_blog_comment(id) when 'All' nil else @@ -166,8 +168,8 @@ class AtController < ApplicationController #BlogComment def find_blog_comment(id) - blog = BlogComment.find(id).blog - blog.users + blog = BlogComment.find(id) + blog.author.watcher_users end end \ No newline at end of file diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index 4a8de5814..a6e383504 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -130,9 +130,16 @@ class BlogCommentsController < ApplicationController params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 @blogComment.safe_attributes = params[:blog_comment] - @blogComment.content = @quote + @blogComment.content @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] - @article.children << @blogComment + if params[:activity_id] + @blogComment.content = params[:blog_comment][:content] + parent = BlogComment.find params[:parent_id] + @blogComment.reply_id = params[:reply_id] + parent.children << @blogComment + else + @blogComment.content = @quote + @blogComment.content + @article.children << @blogComment + end @article.save # @article.update_attribute(:updated_on, @blogComment.updated_on) @user_activity_id = params[:user_activity_id] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 373b4f514..633254978 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -120,6 +120,11 @@ class UsersController < ApplicationController @is_course = params[:is_course] @is_board = params[:is_board] @type = 'Message' + when 'BlogComment' + @reply = BlogComment.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'BlogComment' end respond_to do |format| format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3a28e4b72..3d8d970b5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3141,7 +3141,7 @@ end #获取所有子节点 def get_all_children result, jour - if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) + if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) || (jour.kind_of? BlogComment) jour.children.each do |jour_child| result << jour_child get_all_children result, jour_child diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb index baf4418e9..f612cfe98 100644 --- a/app/views/blog_comments/reply.js.erb +++ b/app/views/blog_comments/reply.js.erb @@ -5,7 +5,7 @@ $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); // init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity'); <% else%> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); //init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity'); <% end %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", 'UserActivity'); \ No newline at end of file diff --git a/app/views/users/_blog_comments_replies.html.erb b/app/views/users/_blog_comments_replies.html.erb new file mode 100644 index 000000000..181f6698a --- /dev/null +++ b/app/views/users/_blog_comments_replies.html.erb @@ -0,0 +1,59 @@ +
          + <% 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" %> + <%= time_from_now(comment.created_on) %> +
          + <% if !comment.parent.nil? && !comment.parent.parent.nil? %> + <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> + <% end %> + <% if !comment.content_detail.blank? %> +
          + <%= comment.content_detail.html_safe %> +
          +
          +
          + + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <% if comment.author == User.current %> + <%= link_to( + l(:button_delete), + {:controller => 'blog_comments',:action => 'destroy', :id => comment.id}, + :method => :delete, + :class => 'fr newsGrey mr10', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete)) %> + <% end %> + +
          +
          +
          +

          + <% end %> +
          +
          +
        • + <% end %> +
        \ No newline at end of file diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index 8a2909ad4..8358a7d23 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -44,6 +44,19 @@

        <% end%> + <% elsif @type == 'BlogComment' %> + <%= form_for('new_form', :url => {:controller => 'blog_comments',:action => 'reply', :id => reply.id, :blog_id => reply.blog.id}, :method => "post", :remote => true) do |f| %> + + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> + <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %> + <%= hidden_field_tag 'parent_id', params[:parent_id], :value => reply.id %> + <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author_id %> +
        + + +
        +

        + <% end%> <% end %>
      diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb index 77510c858..868f92979 100644 --- a/app/views/users/_user_blog.html.erb +++ b/app/views/users/_user_blog.html.erb @@ -45,10 +45,11 @@
      <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> - <% comments = activity.children.reorder("created_on desc").limit(3) %> + <% all_comments = []%> + <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
      - <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/blog_comments_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id}%>
      <% end %> From e19efc1c8a8b75def63caec6280ab792c0bd238d Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Jul 2016 14:44:47 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E7=9A=84=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blog_comments_controller.rb | 25 +++-- app/controllers/users_controller.rb | 8 +- .../_simple_ke_reply_form.html.erb | 9 +- app/views/blog_comments/destroy.js.erb | 7 ++ app/views/blog_comments/quote.js.erb | 4 +- app/views/blog_comments/show.html.erb | 99 ++++++++++--------- app/views/blogs/_homepage.html.erb | 10 +- app/views/messages/_course_show.html.erb | 2 +- .../users/_blog_comment_reply_banner.html.erb | 18 ++++ .../users/_blog_comments_replies.html.erb | 9 +- app/views/users/_reply_to.html.erb | 8 +- app/views/users/_user_blog.html.erb | 7 +- app/views/users/all_journals.js.erb | 4 +- app/views/users/show_all_replies.js.erb | 2 +- public/javascripts/application.js | 34 +++++++ 15 files changed, 169 insertions(+), 77 deletions(-) create mode 100644 app/views/blog_comments/destroy.js.erb create mode 100644 app/views/users/_blog_comment_reply_banner.html.erb diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index a6e383504..dcab1b360 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -70,6 +70,10 @@ class BlogCommentsController < ApplicationController @course.outline = 0 @course.save redirect_to course_path(:id=>params[:course_id]) + elsif params[:user_activity_id] + @article.children.destroy + @article.destroy + redirect_to user_path(User.current.id) else @article.children.destroy @article.destroy @@ -80,6 +84,17 @@ class BlogCommentsController < ApplicationController if params[:course_id] #如果带了course_id过来了,那么这是要跳到课程大纲去的 @article.destroy redirect_to syllabus_course_path(:id=>params[:course_id]) + elsif params[:user_activity_id] + if params[:homepage] && params[:homepage] == "1" + @in_user_homepage = true + end + @user_activity_id = params[:user_activity_id] + @blog_comment = @article.root + @article.destroy + respond_to do |format| + format.js + return + end else root = @article.root @article.destroy @@ -102,13 +117,9 @@ class BlogCommentsController < ApplicationController def quote @blogComment = BlogComment.find(params[:id]) - @subject = @blogComment.title - @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') - @content = "> #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}\n> " @temp = BlogComment.new @course_id = params[:course_id] - @temp.content = "
      #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}
      #{@blogComment.content.html_safe}
      ".html_safe respond_to do | format| format.js end @@ -116,14 +127,13 @@ class BlogCommentsController < ApplicationController #回复 def reply - if params[:homepage] + if params[:homepage] && params[:homepage] == "1" @in_user_homepage = true end if params[:in_user_center] @in_user_center = true end @article = BlogComment.find(params[:id]).root - @quote = params[:quote][:quote] @blogComment = BlogComment.new @blogComment.author = User.current @blogComment.blog = Blog.find(params[:blog_id]) @@ -131,12 +141,13 @@ class BlogCommentsController < ApplicationController params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 @blogComment.safe_attributes = params[:blog_comment] @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] - if params[:activity_id] + if params[:parent_id] @blogComment.content = params[:blog_comment][:content] parent = BlogComment.find params[:parent_id] @blogComment.reply_id = params[:reply_id] parent.children << @blogComment else + @quote = params[:quote][:quote] || "" @blogComment.content = @quote + @blogComment.content @article.children << @blogComment end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 633254978..e7c75eb13 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -92,6 +92,8 @@ class UsersController < ApplicationController @comment = JournalsForMessage.find params[:comment].to_i when 'Message' @comment = Message.find params[:comment].to_i + when 'BlogComment' + @comment = BlogComment.find params[:comment].to_i end end @@ -124,6 +126,7 @@ class UsersController < ApplicationController @reply = BlogComment.find params[:reply_id] @user_activity_id = params[:user_activity_id] @activity_id = params[:activity_id] + @homepage = params[:homepage] @type = 'BlogComment' end respond_to do |format| @@ -3310,7 +3313,10 @@ class UsersController < ApplicationController @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") + @user_activity_id = params[:div_id].to_i if params[:div_id] + @homepage = params[:homepage].to_i + comments = [] + @journals = get_all_children(comments, obj) when 'HomeworkCommon' obj = HomeworkCommon.where('id = ?', params[:id].to_i).first @journals = obj.journals_for_messages.reorder("created_on desc") diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb index 8339ae5ad..7318aaec9 100644 --- a/app/views/blog_comments/_simple_ke_reply_form.html.erb +++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb @@ -3,12 +3,15 @@
      <% if User.current.logged? %>
      - <%= form_for @blog_comment, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => @blogComment.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> - + <%= form_for('new_form', :url => {:controller => 'blog_comments',:action => 'reply', :id => reply.id, :blog_id => reply.blog.id, :user_id => User.current.id}, :method => "post", :html => {:multipart => true}) do |f| %> + + <%#= form_for @blog_comment, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => @blogComment.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> + <% if course_id%> <% end %> - + <%= hidden_field_tag 'parent_id', params[:parent_id], :value => reply.id %> + <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author_id %>
      diff --git a/app/views/blog_comments/destroy.js.erb b/app/views/blog_comments/destroy.js.erb new file mode 100644 index 000000000..c34986977 --- /dev/null +++ b/app/views/blog_comments/destroy.js.erb @@ -0,0 +1,7 @@ +<% if @in_user_homepage %> + <% homepage = BlogComment.find(User.current.blog.homepage_id) %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/homepage', :locals => {:activity => @blog_comment, :user_activity_id => homepage.id}) %>"); +<% else%> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @blog_comment,:user_activity_id =>@user_activity_id}) %>"); +<% end %> +sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", 'UserActivity'); \ No newline at end of file diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb index 9bd226ce1..6d3264a22 100644 --- a/app/views/blog_comments/quote.js.erb +++ b/app/views/blog_comments/quote.js.erb @@ -1,8 +1,6 @@ if($("#reply_message_<%= @blogComment.id%>").length > 0) { - $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'blog_comments/simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:subject =>@subject,:course_id=>@course_id}) %>"); + $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'blog_comments/simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:course_id=>@course_id}) %>"); $(function(){ - $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); - $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); sd_create_editor_from_data(<%= @blogComment.id%>,null,"100%", "<%=@blogComment.class.to_s%>"); }); }else if($("#reply_to_message_<%= @blogComment.id%>").length >0) { diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index b1cd86484..bde98d456 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -91,9 +91,7 @@
      <%= format_time( @article.created_on)%>
      - - - + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>@article.id, :content=>@article.content} %>
      @@ -107,73 +105,84 @@
      - <% count=0 %> - <% if @article.parent %> - <% count=@article.parent.children.count%> - <% else %> - <% count=@article.children.count%> - <% end %> + <% all_comments = []%> + <% count=get_all_children(all_comments, @article).count %>
      - <%# unless count == 0 %> -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>@article, :user_activity_id=>@article.id,:type=>"activity"}%> +
      +
      回复 + <%= count>0 ? "(#{count})" : "" %> + + + <%= render :partial => "praise_tread/praise", :locals => {:activity => @article, :user_activity_id => @article.id, :type => "activity"} %> -
      -
      -
      -
      - <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> +
      +
      +
      + + <% all_comments = []%> + <% comments = get_all_children(all_comments, @article) %> + <% if count > 0 %> +
      + <% comments.each do |comment| %> -
      +
    • - <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> + <%= 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 reply.author.show_name, user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> + <%= time_from_now(comment.created_on) %>
      -
      - <%= reply.content.html_safe%> -
      -
      - <%= format_time(reply.created_on) %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% if !comment.parent.nil? && !comment.parent.parent.nil? %> + <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> + <% end %> + <% if !comment.content_detail.blank? %> +
      + <%= comment.content_detail.html_safe %> +
      +
      +
      + + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - -
      -

      + ) %> + <% end %> + +
      +
      +
      +

      + <% end %>
      -
    • - <% end %> + <% end %>
      + <% end %> - <%# end %>
      <% if !@article.locked? && User.current.logged?%>
      diff --git a/app/views/blogs/_homepage.html.erb b/app/views/blogs/_homepage.html.erb index 140f547cb..d5a5c0d64 100644 --- a/app/views/blogs/_homepage.html.erb +++ b/app/views/blogs/_homepage.html.erb @@ -48,14 +48,16 @@
      - <% count=activity.children.count %> + <% all_comments = []%> + <% count=get_all_children(all_comments, activity).count %>
      - <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> + <%= render :partial => 'users/blog_comment_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :homepage => 1} %> - <% comments = activity.children.reorder("created_on desc").limit(3) %> + <% all_comments = []%> + <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
      - <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/blog_comments_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id, :homepage => 1}%>
      <% end %> diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 232be1f35..b37540810 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -116,7 +116,7 @@
      <% if !reply.parent.nil? && !reply.parent.parent.nil? %> <%= render :partial => 'users/message_contents', :locals => {:comment => reply}%> - <% end %> + <% end %>
      <%= reply.content.html_safe%>
      diff --git a/app/views/users/_blog_comment_reply_banner.html.erb b/app/views/users/_blog_comment_reply_banner.html.erb new file mode 100644 index 000000000..496cd2c7c --- /dev/null +++ b/app/views/users/_blog_comment_reply_banner.html.erb @@ -0,0 +1,18 @@ +
      +
      + 回复 + ︿ + <%= count>0 ? "(#{count})" : "" %> + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + +
      +
      <%#= format_date(activity.updated_on) %>
      + <%if count>3 %> + + <% end %> +
      \ No newline at end of file diff --git a/app/views/users/_blog_comments_replies.html.erb b/app/views/users/_blog_comments_replies.html.erb index 181f6698a..b4a134b7b 100644 --- a/app/views/users/_blog_comments_replies.html.erb +++ b/app/views/users/_blog_comments_replies.html.erb @@ -31,18 +31,19 @@ <%= link_to( l(:button_reply), - {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id}, + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id, :homepage => homepage}, :remote => true, :method => 'get', - :title => l(:button_reply)) %> + :title => l(:button_reply)) if !comment.root.locked? %> <% if comment.author == User.current %> <%= link_to( l(:button_delete), - {:controller => 'blog_comments',:action => 'destroy', :id => comment.id}, + {:controller => 'blog_comments',:action => 'destroy', :id => comment.id, :user_activity_id => user_activity_id, :homepage => homepage}, :method => :delete, - :class => 'fr newsGrey mr10', + :remote => true, + :class => 'fr mr20', :data => {:confirm => l(:text_are_you_sure)}, :title => l(:button_delete)) %> <% end %> diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index 8358a7d23..5c3f2a70b 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -36,8 +36,6 @@ <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author.id %> <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> -
      @@ -45,12 +43,14 @@

      <% end%> <% elsif @type == 'BlogComment' %> - <%= form_for('new_form', :url => {:controller => 'blog_comments',:action => 'reply', :id => reply.id, :blog_id => reply.blog.id}, :method => "post", :remote => true) do |f| %> + <%#= form_for reply, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => reply.id, :blog_id => reply.blog.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> + + <%= form_for('new_form', :url => {:controller => 'blog_comments',:action => 'reply', :id => reply.id, :blog_id => reply.blog.id, :user_id => User.current.id}, :method => "post", :remote => true) do |f| %> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> - <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %> <%= hidden_field_tag 'parent_id', params[:parent_id], :value => reply.id %> <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author_id %> + <%= hidden_field_tag 'homepage', params[:homepage], :value => @homepage %>
      diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb index 868f92979..a19bfc016 100644 --- a/app/views/users/_user_blog.html.erb +++ b/app/views/users/_user_blog.html.erb @@ -41,15 +41,16 @@
      - <% count=activity.children.count %> + <% all_comments = []%> + <% count=get_all_children(all_comments, activity).count %>
      - <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> + <%= render :partial => 'users/blog_comment_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :homepage => 0} %> <% all_comments = []%> <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
      - <%= render :partial => 'users/blog_comments_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id}%> + <%= render :partial => 'users/blog_comments_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id, :homepage => 0}%>
      <% end %> diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb index d03e13742..30ae23bfb 100644 --- a/app/views/users/all_journals.js.erb +++ b/app/views/users/all_journals.js.erb @@ -3,7 +3,9 @@ $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :p <% elsif params[:type] == 'JournalsForMessage' %> $('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :allow_delete => @allow_delete, :activity_id =>params[:id].to_i}) %>'); <% elsif params[:type] == 'Message' %> -$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i,:is_course => @is_course, :is_board => @is_board}) %>'); +$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i,:is_course => @is_course, :is_board => @is_board}) %>'); +<% elsif params[:type] == 'BlogComment' %> +$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/blog_comments_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i, :homepage => @homepage}) %>'); <% else %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals}) %>'); <% end %> diff --git a/app/views/users/show_all_replies.js.erb b/app/views/users/show_all_replies.js.erb index ae8803653..2d4321bce 100644 --- a/app/views/users/show_all_replies.js.erb +++ b/app/views/users/show_all_replies.js.erb @@ -1,7 +1,7 @@ <% unless @comment.parent.nil? %> <% if params[:type] == 'JournalsForMessage' && (@comment.jour_type == 'Principal' || @comment.jour_type == 'Course') %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>"); - <% elsif @comment.class.to_s == 'Message' %> + <% elsif (@comment.class.to_s == 'Message' || @comment.class.to_s == 'BlogComment' ) %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>"); <% else %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>"); diff --git a/public/javascripts/application.js b/public/javascripts/application.js index a342a9608..fb7c6cda2 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1409,6 +1409,40 @@ function expand_message_reply(container, btnid, id, type, div_id, is_course, is_ } } +function expand_blog_comment_reply(container, btnid, id, type, div_id, homepage) { + var target = $(container); + var btn = $(btnid); + if (btn.data('init') == '0') { + btn.data('init', 1); + $.get( + '/users/all_journals', + { + type: type, + id: id, + div_id: div_id, + homepage: homepage + }, + function(data) { + + } + ); + btn.html('收起回复'); + //target.show(); + } else if(btn.data('init') == '1') { + btn.data('init', 3); + btn.html('展开更多'); + target.hide(); + target.eq(0).show(); + target.eq(1).show(); + target.eq(2).show(); + } + else { + btn.data('init', 1); + btn.html('收起回复'); + target.show(); + } +} + function expand_reply_homework(container, btnid, id, type, div_id, is_in_course, course_activity, user_activity_id) { var target = $(container); var btn = $(btnid); From b77779ca55f9ae4ac5b002461c3ad7f08baec7c1 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Jul 2016 17:23:48 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=9A=84=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E5=A4=8D=E5=92=8C=E7=BB=84=E7=BB=87=E5=B8=96?= =?UTF-8?q?=E5=AD=90=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? %> -