迁移文件中添加打印收据

添加未读消息样式
This commit is contained in:
huang 2015-09-02 18:35:12 +08:00
parent 4c76292e5e
commit 8b9eabd027
6 changed files with 21 additions and 10 deletions

View File

@ -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

View File

@ -29,6 +29,11 @@
</div>
<div class="resources mt10" id="users_setting">
<div>
<% if params[:type].nil? %>
<div class="newsReadSetting">
有&nbsp;<span class="c_red"><%= User.current.count_new_message %></span>&nbsp;封未读<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? %>

View File

@ -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|

View File

@ -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

View File

@ -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

View File

@ -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