From 0aa8c5b5ccbbb0d7338b1bd761e07f1222aba5fb Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 9 Sep 2015 17:43:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=B3=BB=E7=BB=9F=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=80=9A=E7=9F=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/system_messages_controller.rb | 4 ++++ app/controllers/users_controller.rb | 2 ++ app/views/users/user_messages.html.erb | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index 21b9ae9b8..588e13c5e 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -33,6 +33,10 @@ class SystemMessagesController < ApplicationController # POST /products # POST /products.json def create + unless User.current.admin? + render_403 + return + end @system_messages = SystemMessage.new @system_messages.content = params[:system_message][:content] @system_messages.user_id = User.current.id diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5680a333e..23106c954 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -114,8 +114,10 @@ class UsersController < ApplicationController message_new_time.save else 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) end + @user_system_messages = SystemMessage.where("created_at >?", message_last_time) # 当前用户查看消息,则设置消息为已读 if params[:viewed] == "all" course_querys = @user.course_messages diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a37ce30ff..e36fd4f32 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -39,6 +39,18 @@ <% end %> <% end %> + <%# 系统消息 %> + <% @user_system_messages.each do |usm| %> + + <% end %> <%# 课程消息 %> <% unless @message_alls.nil? %> <% @message_alls.each do |ma| %>