系统发出的加入班级\项目\竞赛消息通知,点击后自动变为已读(并优化消息代码结构)
This commit is contained in:
parent
1f2fadc9f6
commit
2cad08614f
|
@ -7,6 +7,7 @@ class ContestsController < ApplicationController
|
|||
helper :attachments
|
||||
helper :files
|
||||
include AvatarHelper
|
||||
include ApplicationHelper
|
||||
|
||||
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :private_or_public, :switch_role, :set_invite_code_halt, :renew,
|
||||
:member, :export_all_members, :feedback]
|
||||
|
@ -18,8 +19,7 @@ class ContestsController < ApplicationController
|
|||
|
||||
def show
|
||||
#更新创建课程消息状态
|
||||
contest_request_messages = ContestMessage.where("user_id = #{User.current.id} and contest_id = #{@contest.id} and contest_message_type in ('ContestRequestDealResult', 'JoinContest', 'RemoveFromContest') and viewed = 0")
|
||||
contest_request_messages.update_all(:viewed => true)
|
||||
update_messsages_to_viewed("ContestMessage", @contest)
|
||||
@left_nav_type = 1
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
@ -456,7 +456,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
def member
|
||||
# 当前用户查看班级消息时,设置消息为已读
|
||||
update_messsages_to_viewed("CourseMessage", "JoinCourse", @course)
|
||||
update_messsages_to_viewed("CourseMessage", @course)
|
||||
## 有角色参数的才是课程,没有的就是项目
|
||||
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
||||
@render_file = 'new_member_list'
|
||||
|
|
|
@ -72,6 +72,7 @@ class ProjectsController < ApplicationController
|
|||
include UsersHelper
|
||||
### added by william
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
include ApplicationHelper
|
||||
|
||||
# 仅仅为了转换Gitlab地址
|
||||
def project_home
|
||||
|
@ -575,7 +576,7 @@ class ProjectsController < ApplicationController
|
|||
if params[:message_id]
|
||||
message_invite(params[:message_id], params[:key])
|
||||
end
|
||||
update_message_status(User.current, @project)
|
||||
update_messsages_to_viewed("ForgeMessage", @project)
|
||||
# params[:login]为邮箱邀请用户加入,主要功能:
|
||||
# 1、自动注册
|
||||
# 2、加入项目、创建角色
|
||||
|
|
|
@ -1037,14 +1037,24 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
# 更新各类消息为已读
|
||||
def update_messsages_to_viewed(message_type, forge_message_type, forge_message_id)
|
||||
def update_messsages_to_viewed(message_type, forge_message_id)
|
||||
if(message_type == "CourseMessage")
|
||||
query = CourseMessage.where(:course_message_type => forge_message_type,
|
||||
query = CourseMessage.where(:course_message_type => ["JoinCourse", "RemoveFromCourse"],
|
||||
:user_id => User.current,
|
||||
:course_id => forge_message_id,
|
||||
:viewed => false).first
|
||||
query.update_attribute(:viewed, true) unless query.nil?
|
||||
:viewed => false)
|
||||
elsif(message_type == "ForgeMessage")
|
||||
query = ForgeMessage.where(:forge_message_type => ["ProjectInvite", "JoinProject", "RemoveFromProject"],
|
||||
:user_id => User.current,
|
||||
:project_id => forge_message_id,
|
||||
:viewed => false)
|
||||
elsif(message_type == "ContestMessage")
|
||||
query = ContestMessage.where(:contest_message_type => ["ContestRequestDealResult", "JoinContest", "RemoveFromContest"],
|
||||
:user_id => User.current,
|
||||
:contest_id => forge_message_id,
|
||||
:viewed => false)
|
||||
end
|
||||
query.update_all(:viewed => true) unless query.blank?
|
||||
end
|
||||
|
||||
def show_attachment_tip container_id, container_type
|
||||
|
|
Loading…
Reference in New Issue