消息结构优化

This commit is contained in:
daiao 2017-02-15 10:03:09 +08:00
parent bc0be4c890
commit 1f2fadc9f6
2 changed files with 14 additions and 0 deletions

View File

@ -9,6 +9,7 @@ class CoursesController < ApplicationController
helper :attachments
helper :files
helper :activity_notifys
include ApplicationHelper
before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
menu_item :overview
@ -454,6 +455,8 @@ class CoursesController < ApplicationController
end
def member
# 当前用户查看班级消息时,设置消息为已读
update_messsages_to_viewed("CourseMessage", "JoinCourse", @course)
## 有角色参数的才是课程,没有的就是项目
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
@render_file = 'new_member_list'

View File

@ -1036,6 +1036,17 @@ module ApplicationHelper
return @result
end
# 更新各类消息为已读
def update_messsages_to_viewed(message_type, forge_message_type, forge_message_id)
if( message_type == "CourseMessage")
query = CourseMessage.where(:course_message_type => forge_message_type,
:user_id => User.current,
:course_id => forge_message_id,
:viewed => false).first
query.update_attribute(:viewed, true) unless query.nil?
end
end
def show_attachment_tip container_id, container_type
atts = Attachment.where(:container_id => container_id, :container_type => container_type, :is_public => 0)
atts.count > 0 ? true :false