diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1744fd9af..c070decb8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -292,17 +292,20 @@ class UsersController < ApplicationController #status 1 同意 2 拒绝 def dealwith_apply_homework @msg = CourseMessage.find(params[:msg_id]) + ah = ApplyHomework.where("user_id = ? and homework_common_id = ?",@msg.apply_user_id, @msg.course_message_id) case params[:agree] when 'Y' - ah = ApplyHomework.where("user_id = ? and homework_common_id = ?",@msg.apply_user_id, @msg.course_message_id) unless ah.empty? ah.first.update_column('status', 2) - CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>5,:apply_result=>1) + CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>1) @msg.update_attributes(:apply_result=>1,:viewed=>1) end when 'N' - CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>5,:apply_result=>2) - @msg.update_attributes(:apply_result=>2,:viewed=>1) + unless ah.empty? + ah.first.update_column('status', 3) + CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>2) + @msg.update_attributes(:apply_result=>2,:viewed=>1) + end end respond_to do |format| format.js diff --git a/app/models/apply_homework.rb b/app/models/apply_homework.rb index c92eccca6..0a7c505a4 100644 --- a/app/models/apply_homework.rb +++ b/app/models/apply_homework.rb @@ -1,5 +1,5 @@ class ApplyHomework < ActiveRecord::Base - #status:1. 待审核 2.审核通过 + #status:1. 待审核 2.审核通过 3.已拒绝 belongs_to :user belongs_to :homework_common attr_accessible :status, :user_id, :homework_common_id diff --git a/app/models/course_message.rb b/app/models/course_message.rb index 3375aa5ab..07bfb22de 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -1,7 +1,7 @@ class CourseMessage < ActiveRecord::Base # status说明: status在课程不同的类型,区分不同的功能 status = 9 作品的提交记录 # HomeworkCommon:status: - # nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败; 5:申请引用作业 + # nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败; 5:申请引用作业, 6:申请结果 # apply_user_id: 申请者的用户id attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status, :apply_user_id, :apply_result diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index f36f8a63c..33c9d7f8d 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -91,16 +91,19 @@
- <% unless @replies.empty? %>
-
回复(<%=@reply_count %>)
-
- +
回复 + <%= @reply_count>0 ? "(#{@reply_count})" : "" %> + + <% if @topic.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>@topic, :user_activity_id=>@topic.id,:type=>"activity"}%> + <% end %> + +
+ <% unless @replies.empty? %>
<% @replies.each_with_index do |reply,i| %>