parent
4c76292e5e
commit
8b9eabd027
|
@ -106,16 +106,18 @@ class UsersController < ApplicationController
|
|||
return
|
||||
end
|
||||
# 当前用户查看消息,则设置消息为已读
|
||||
# course_querys = @user.course_messages
|
||||
# forge_querys = @user.forge_messages
|
||||
# user_querys = @user.user_feedback_messages
|
||||
# forum_querys = @user.memo_messages
|
||||
# if User.current.id == @user.id
|
||||
# course_querys.update_all(:viewed => true)
|
||||
# forge_querys.update_all(:viewed => true)
|
||||
# user_querys.update_all(:viewed => true)
|
||||
# forum_querys.update_all(:viewed => true)
|
||||
# end
|
||||
if params[:viewed] == "all"
|
||||
course_querys = @user.course_messages
|
||||
forge_querys = @user.forge_messages
|
||||
user_querys = @user.user_feedback_messages
|
||||
forum_querys = @user.memo_messages
|
||||
if User.current.id == @user.id
|
||||
course_querys.update_all(:viewed => true)
|
||||
forge_querys.update_all(:viewed => true)
|
||||
user_querys.update_all(:viewed => true)
|
||||
forum_querys.update_all(:viewed => true)
|
||||
end
|
||||
end
|
||||
# @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count
|
||||
case params[:type]
|
||||
when nil
|
||||
|
|
|
@ -29,6 +29,11 @@
|
|||
</div>
|
||||
<div class="resources mt10" id="users_setting">
|
||||
<div>
|
||||
<% if params[:type].nil? %>
|
||||
<div class="newsReadSetting">
|
||||
有 <span class="c_red"><%= User.current.count_new_message %></span> 封未读<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @message_alls.count >0 %>
|
||||
<%# 课程消息 %>
|
||||
<% unless @message_alls.nil? %>
|
||||
|
|
|
@ -3,6 +3,7 @@ class CourseMessages < ActiveRecord::Migration
|
|||
def up
|
||||
Course.all.each do |course|
|
||||
transaction do
|
||||
put course.id
|
||||
course.course_messages << CourseMessage.new(:user_id => course.tea_id,:course_id => course.id)
|
||||
# 作业
|
||||
course.homework_commons.each do |homework_common|
|
||||
|
|
|
@ -11,6 +11,7 @@ class UpdateMessageTime < ActiveRecord::Migration
|
|||
cmessage.created_at = cmessage.course_message.created_on
|
||||
end
|
||||
cmessage.save
|
||||
puts cmessage.id
|
||||
|
||||
course_all_message = MessageAll.where("message_type = '#{cmessage.class.to_s}' and message_id = '#{cmessage.id}'").first
|
||||
course_all_message.created_at = cmessage.created_at
|
||||
|
|
|
@ -11,6 +11,7 @@ class UpdateForgeMessageTime < ActiveRecord::Migration
|
|||
fmessage.created_at = fmessage.forge_message.created_on
|
||||
end
|
||||
fmessage.save
|
||||
puts fmessage.id
|
||||
|
||||
forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first
|
||||
forge_all_message.created_at = fmessage.created_at
|
||||
|
|
|
@ -11,6 +11,7 @@ class UpdateMemoMessageTime < ActiveRecord::Migration
|
|||
memo_message.created_at = memo_message.memo.created_on
|
||||
end
|
||||
memo_message.save
|
||||
puts memo_message.id
|
||||
|
||||
memo_messages = MessageAll.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first
|
||||
memo_messages.created_at = memo_message.created_at
|
||||
|
|
Loading…
Reference in New Issue