消息通知
This commit is contained in:
parent
6d6445465b
commit
e1c89c6662
|
@ -498,7 +498,6 @@ class UsersController < ApplicationController
|
|||
return render_403
|
||||
end
|
||||
# 初始化/更新 点击按钮时间, 24小时内显示系统消息
|
||||
update_onclick_time
|
||||
user_all_messages = MessageAll.where(:user_id => @user.id).includes(:message)
|
||||
# 全部设为已读
|
||||
|
||||
|
@ -516,15 +515,15 @@ class UsersController < ApplicationController
|
|||
else
|
||||
@message_alls = user_all_messages.where(message_type: %w(SystemMessage ContestMessage OrgMessage))
|
||||
end
|
||||
@unred_all_messages = @message_alls.map{|m| (m.message_type != "SystemMessage") &&( m.message.try(:viewed) == 0)}.size
|
||||
@unred_all_messages = @user.count_new_message
|
||||
@message_alls = @message_alls.order("created_at desc")
|
||||
|
||||
#点击进入tab后,全部更新为已读,全部页面除外
|
||||
|
||||
@limit = 20
|
||||
@message_count = @message_alls.count
|
||||
# @message_alls = paginateHelper @message_alls, 25
|
||||
@message_all_pages = Paginator.new @message_count, @limit, params['page'] || 1
|
||||
@offset ||= @message_all_pages.offset
|
||||
# @message_alls = messages_all
|
||||
@message_alls = paginateHelper @message_alls, @limit
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
|
|
@ -434,14 +434,16 @@ class User < Principal
|
|||
issues_count + apply_messages_count
|
||||
end
|
||||
|
||||
|
||||
# 查询指派给我的缺陷记录
|
||||
def count_new_issue_assign_to
|
||||
self.issue_assigns
|
||||
end
|
||||
|
||||
# 新消息统计
|
||||
# 新消息统计,
|
||||
def count_new_message
|
||||
if OnclickTime.where("user_id =?", User.current).first.nil?
|
||||
message_new_time = OnclickTime.where("user_id =?", User.current).first
|
||||
if message_new_time.nil?
|
||||
message_new_time = OnclickTime.new
|
||||
message_new_time.user_id = User.current.id
|
||||
# 第一次初始化点击铃铛时间
|
||||
|
@ -461,7 +463,10 @@ class User < Principal
|
|||
org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).count
|
||||
applied_count = AppliedMessage.where("user_id=? and viewed =? and created_at >?", user.id, 0, onclick_time).count
|
||||
blog_message_count = BlogMessage.where("user_id=? and viewed=? and created_at >?", user.id, 0, onclick_time).count
|
||||
message_new_time.update_attribute(:onclick_time, Time.now)
|
||||
messages_count = course_count + contest_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count + blog_message_count
|
||||
|
||||
|
||||
end
|
||||
|
||||
# 查询指派给我的缺陷记录
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
</div>
|
||||
|
||||
<div class="navHomepageNews" id="user_messages">
|
||||
<a href="<%= user_path(User.current, :click_user_message => true) %>" class="fl"><i class="iconfont icon-xiaoxilingdang fontGrey4 f22 fl mt7"></i></a>
|
||||
<a href="<%= user_message_path(User.current,click_user_message: true) %>" class="fl"><i class="iconfont icon-xiaoxilingdang fontGrey4 f22 fl mt7"></i></a>
|
||||
<% new_message_count = User.current.count_new_message.to_i %>
|
||||
<% if new_message_count > 0 %>
|
||||
<%#= link_to new_message_count, user_path(User.current, :click_user_message => true), :class => "newsActive", :target => "_Blank" %>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
<div class="l_InfoNav mb20">
|
||||
<li class="clearfix active">
|
||||
<a href="javascript:void(0)" class="ml30">消息</a>
|
||||
<%= link_to "消息", user_message_path(current_user), remote: true, class: "ml30" %>
|
||||
<span class="readingNum" id="unread-message-count-<%= @user.login %>"><%= @unred_all_messages %></span>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
|
|
Loading…
Reference in New Issue