diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index a242587fb..965aacab0 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -177,6 +177,7 @@ class MessagesController < ApplicationController @reply.board = @board @reply.safe_attributes = params[:reply] @reply.content = @quote + @reply.content + @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] @topic.children << @reply #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? @@ -185,41 +186,18 @@ class MessagesController < ApplicationController update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE end - # 与我相关动态的记录add start - if(@board && @board.course) #项目的先不管 - notifyto_arr = {} - notifyto_arr[@topic.author_id] = @topic.author_id - if( params[:parent_topic] != nil && params[:parent_topic] != '') - parent_topic = Message.find(params[:parent_topic]) - notifyto_arr[parent_topic.author_id] = parent_topic.author_id - end - notifyto_arr.each do |k,user_id| - if(user_id != User.current.id) - notify = ActivityNotify.new() - if(@board.course) - notify.activity_container_id = @board.course_id - notify.activity_container_type = 'Course' - else - notify.activity_container_id = @board.project_id - notify.activity_container_type = 'Project' - end - notify.activity_id = @reply.id - notify.activity_type = 'Message' - notify.notify_to = user_id - notify.is_read = 0 - notify.save() - end - end - end - # 与我相关动态的记录add end - call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) attachments = Attachment.attach_files(@reply, params[:attachments]) render_attachment_warning_if_needed(@reply) else #render file: 'messages#show', layout: 'base_courses' end - if params[:is_board] + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + elsif params[:is_board] if @project redirect_to project_boards_path(@project) elsif @course diff --git a/app/views/messages/reply.js.erb b/app/views/messages/reply.js.erb new file mode 100644 index 000000000..b1a18a8af --- /dev/null +++ b/app/views/messages/reply.js.erb @@ -0,0 +1,3 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); + +init_KindEditor_data(<%= @user_activity_id%>); \ No newline at end of file diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index 0f3201e64..bd660ca7d 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -1,5 +1,5 @@ -
-
+
+
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
@@ -12,7 +12,6 @@ <% end %> TO <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%> - <%#= link_to activity.course.name.to_s+"(课程讨论区)", course_path(activity.course), :class => "newsBlue ml15 mr5"%>
<% if activity.parent_id.nil? %> @@ -26,14 +25,14 @@
-
帖子描述: +
帖子描述: <% if activity.parent_id.nil? %> <%= activity.content.to_s.html_safe%> <% else %> <%= activity.parent.content.to_s.html_safe%> <% end %>
- - +
+ <% activity= activity.parent_id.nil? ? activity:activity.parent%> <% replies_all_i = 0 %> <% unless activity.children.empty? %> -
+
    <% activity.children.reorder("created_on desc").each do |reply|%> <% replies_all_i=replies_all_i+1 %> diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 4e705157a..a5325342c 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -1,4 +1,14 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %> + <% user_activities.each do |user_activity| if user_activities %>