系统发出的加入班级\项目\竞赛消息通知,点击后自动变为已读(并优化消息代码结构)
This commit is contained in:
parent
1f2fadc9f6
commit
2cad08614f
|
@ -7,7 +7,8 @@ class ContestsController < ApplicationController
|
||||||
helper :attachments
|
helper :attachments
|
||||||
helper :files
|
helper :files
|
||||||
include AvatarHelper
|
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,
|
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]
|
:member, :export_all_members, :feedback]
|
||||||
before_filter :is_logged, :only => [:index, :new, :create]
|
before_filter :is_logged, :only => [:index, :new, :create]
|
||||||
|
@ -18,8 +19,7 @@ class ContestsController < ApplicationController
|
||||||
|
|
||||||
def show
|
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")
|
update_messsages_to_viewed("ContestMessage", @contest)
|
||||||
contest_request_messages.update_all(:viewed => true)
|
|
||||||
@left_nav_type = 1
|
@left_nav_type = 1
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -456,7 +456,7 @@ class CoursesController < ApplicationController
|
||||||
|
|
||||||
def member
|
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)))
|
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
||||||
@render_file = 'new_member_list'
|
@render_file = 'new_member_list'
|
||||||
|
|
|
@ -72,6 +72,7 @@ class ProjectsController < ApplicationController
|
||||||
include UsersHelper
|
include UsersHelper
|
||||||
### added by william
|
### added by william
|
||||||
include ActsAsTaggableOn::TagsHelper
|
include ActsAsTaggableOn::TagsHelper
|
||||||
|
include ApplicationHelper
|
||||||
|
|
||||||
# 仅仅为了转换Gitlab地址
|
# 仅仅为了转换Gitlab地址
|
||||||
def project_home
|
def project_home
|
||||||
|
@ -575,7 +576,7 @@ class ProjectsController < ApplicationController
|
||||||
if params[:message_id]
|
if params[:message_id]
|
||||||
message_invite(params[:message_id], params[:key])
|
message_invite(params[:message_id], params[:key])
|
||||||
end
|
end
|
||||||
update_message_status(User.current, @project)
|
update_messsages_to_viewed("ForgeMessage", @project)
|
||||||
# params[:login]为邮箱邀请用户加入,主要功能:
|
# params[:login]为邮箱邀请用户加入,主要功能:
|
||||||
# 1、自动注册
|
# 1、自动注册
|
||||||
# 2、加入项目、创建角色
|
# 2、加入项目、创建角色
|
||||||
|
|
|
@ -1037,14 +1037,24 @@ module ApplicationHelper
|
||||||
end
|
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")
|
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,
|
:user_id => User.current,
|
||||||
:course_id => forge_message_id,
|
:course_id => forge_message_id,
|
||||||
:viewed => false).first
|
:viewed => false)
|
||||||
query.update_attribute(:viewed, true) unless query.nil?
|
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
|
end
|
||||||
|
query.update_all(:viewed => true) unless query.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_attachment_tip container_id, container_type
|
def show_attachment_tip container_id, container_type
|
||||||
|
|
Loading…
Reference in New Issue