完成系统消息通知功能
This commit is contained in:
parent
13397363db
commit
0aa8c5b5cc
|
@ -33,6 +33,10 @@ class SystemMessagesController < ApplicationController
|
||||||
# POST /products
|
# POST /products
|
||||||
# POST /products.json
|
# POST /products.json
|
||||||
def create
|
def create
|
||||||
|
unless User.current.admin?
|
||||||
|
render_403
|
||||||
|
return
|
||||||
|
end
|
||||||
@system_messages = SystemMessage.new
|
@system_messages = SystemMessage.new
|
||||||
@system_messages.content = params[:system_message][:content]
|
@system_messages.content = params[:system_message][:content]
|
||||||
@system_messages.user_id = User.current.id
|
@system_messages.user_id = User.current.id
|
||||||
|
|
|
@ -114,8 +114,10 @@ class UsersController < ApplicationController
|
||||||
message_new_time.save
|
message_new_time.save
|
||||||
else
|
else
|
||||||
message_new_time = OnclickTime.where("user_id =?", User.current).first
|
message_new_time = OnclickTime.where("user_id =?", User.current).first
|
||||||
|
message_last_time = message_new_time.onclick_time
|
||||||
message_new_time.update_attributes(:onclick_time => Time.now)
|
message_new_time.update_attributes(:onclick_time => Time.now)
|
||||||
end
|
end
|
||||||
|
@user_system_messages = SystemMessage.where("created_at >?", message_last_time)
|
||||||
# 当前用户查看消息,则设置消息为已读
|
# 当前用户查看消息,则设置消息为已读
|
||||||
if params[:viewed] == "all"
|
if params[:viewed] == "all"
|
||||||
course_querys = @user.course_messages
|
course_querys = @user.course_messages
|
||||||
|
|
|
@ -39,6 +39,18 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%# 系统消息 %>
|
||||||
|
<% @user_system_messages.each do |usm| %>
|
||||||
|
<ul class="homepageNewsList fl">
|
||||||
|
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);">ddddddddddddddd</a></li>
|
||||||
|
<li class="homepageNewsPubType fl">Trustiep平台<span class="homepageNewsType fl">发布新消息:</span></li>
|
||||||
|
<li class="homepageNewsContent fl">
|
||||||
|
<%= link_to usm.content, {:controller => 'system_messages', :action => 'index'},
|
||||||
|
:class =>"newsGrey",
|
||||||
|
:title => "#{usm.content.html_safe}" %></li>
|
||||||
|
<li class="homepageNewsTime fl"><%= time_tag(usm.created_at).html_safe %> </li>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
<%# 课程消息 %>
|
<%# 课程消息 %>
|
||||||
<% unless @message_alls.nil? %>
|
<% unless @message_alls.nil? %>
|
||||||
<% @message_alls.each do |ma| %>
|
<% @message_alls.each do |ma| %>
|
||||||
|
|
Loading…
Reference in New Issue