Merge branch 'develop' into 'develop'

周五bug修复



See merge request !128
This commit is contained in:
陈晓婷 2017-01-13 18:53:48 +08:00
commit 20f999e33d
5 changed files with 31 additions and 32 deletions

View File

@ -36,7 +36,7 @@ class UsersController < ApplicationController
#
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :unsolved_issues_list, :unfinished_homework_list, :user_manage_homeworks,
:unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :update_message_viewed,
:anonymous_evaluation_list,:unfinished_test_list, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :user_receive_homeworks,
:unapproval_applied_list, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist, :user_manage_issues, :user_receive_issues,
@ -489,9 +489,9 @@ class UsersController < ApplicationController
# 初始化/更新 点击按钮时间, 24小时内显示系统消息
update_onclick_time
# 全部设为已读
if params[:viewed] == "all"
update_message_viewed(@user)
end
# if params[:viewed] == "all"
# update_message_viewed(@user)
# end
# @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@ -571,27 +571,28 @@ class UsersController < ApplicationController
end
# 消息设置为已读
def update_message_viewed(user)
def update_message_viewed
if User.current.id == @user.id
course_querys = CourseMessage.where("user_id =? and viewed =?", user, 0)
forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0)
user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0)
forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0)
org_querys = OrgMessage.where("user_id=? and viewed=0", user)
at_querys = AtMessage.where("user_id=? and viewed=0", user)
contest_querys = ContestMessage.where(:user_id => user, :viewed => 0)
blog_querys = BlogMessage.where(:user_id => user, :viewed => 0)
applied_querys = AppliedMessage.where("user_id=? and viewed =?", user, 0)
course_querys.update_all(:viewed => true) unless course_querys.nil?
forge_querys.update_all(:viewed => true) unless forge_querys.nil?
user_querys.update_all(:viewed => true) unless user_querys.nil?
forum_querys.update_all(:viewed => true) unless forum_querys.nil?
org_querys.update_all(:viewed => true) unless org_querys.nil?
at_querys.update_all(:viewed => true) unless at_querys.nil?
contest_querys.update_all(:viewed => true) unless contest_querys.nil?
blog_querys.update_all(:viewed => true) unless blog_querys.nil?
applied_querys.update_all(:viewed => true) unless applied_querys.nil?
course_querys = CourseMessage.where("user_id =? and viewed =?", @user.id, 0)
forge_querys = ForgeMessage.where("user_id =? and viewed =?", @user.id, 0)
user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", @user.id, 0)
forum_querys = MemoMessage.where("user_id =? and viewed =?", @user.id, 0)
org_querys = OrgMessage.where("user_id=? and viewed=0", @user.id)
at_querys = AtMessage.where("user_id=? and viewed=0", @user.id)
contest_querys = ContestMessage.where(:user_id => @user.id, :viewed => 0)
blog_querys = BlogMessage.where(:user_id => @user.id, :viewed => 0)
applied_querys = AppliedMessage.where("user_id=? and viewed =?", @user.id, 0)
course_querys.update_all(:viewed => true) unless course_querys.nil?
forge_querys.update_all(:viewed => true) unless forge_querys.nil?
user_querys.update_all(:viewed => true) unless user_querys.nil?
forum_querys.update_all(:viewed => true) unless forum_querys.nil?
org_querys.update_all(:viewed => true) unless org_querys.nil?
at_querys.update_all(:viewed => true) unless at_querys.nil?
contest_querys.update_all(:viewed => true) unless contest_querys.nil?
blog_querys.update_all(:viewed => true) unless blog_querys.nil?
applied_querys.update_all(:viewed => true) unless applied_querys.nil?
end
redirect_to user_path(@user)
end
# 系统消息
@ -2011,9 +2012,6 @@ class UsersController < ApplicationController
def show
if User.current == @user
# 全部设为已读
if params[:viewed] == "set_viewed"
update_message_viewed(@user)
end
# 自己的主页显示消息
messages_all = MessageAll.where(:user_id => @user.id)
@message_count = messages_all.count

View File

@ -39,10 +39,10 @@
|
<%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%>
<% elsif ma.status == 1%> <!-- 同意 -->
您已同意申请
<%= Course.find(ma.course_id).teacher.show_name %>已同意
<% elsif ma.status == 2%> <!-- 拒绝 -->
您已拒绝申请
<%end %>
<%= Course.find(ma.course_id).teacher.show_name %>已拒绝
<% end %>
</span>
</li>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>

View File

@ -726,9 +726,9 @@
</div>
<li class="messageOperateContents fl">
<% if ma.status == 1 %>
<span class="user_hiddent fl" title="<%=User.find(ma.course_message_id).show_name %>"><%= User.find(ma.course_message_id).show_name %></span><span>已通过</span>
<span class="fl" title="<%= User.find(ma.course_message_id).show_name %>已同意"><%= User.find(ma.course_message_id).show_name %>已同意</span>
<% else %>
<span class="user_hiddent fl" title="<%=User.find(ma.course_message_id).show_name %>"><%= User.find(ma.course_message_id).show_name %></span><span>已拒绝</span>
<span class="fl" title="<%= User.find(ma.course_message_id).show_name %>已拒绝"><%= User.find(ma.course_message_id).show_name %>已拒绝</span>
<% end %>
</li>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>

View File

@ -5,7 +5,7 @@
<% count = unviewed_message(@user) %>
<span class="fr" style="margin-top:5px;">
<% unless (count == 0 || User.current != @user) %>
<%= link_to "全部设为已读", user_path(User.current, :viewed => 'set_viewed'), :class => "fl mr10" %>
<%= link_to "全部设为已读", update_message_viewed_user_path(@user), :class => "fl mr10" %>
<% end %>
<span class="fl">共 <span style="color: red;"><%= @message_count %></span> 个消息</span>
</span>

View File

@ -699,6 +699,7 @@ RedmineApp::Application.routes.draw do
get 'choose_user_course'
get 'user_import_resource'
match 'watch_projects', :to => 'users#watch_projects', :via => :get
get 'update_message_viewed'
#
# added by bai
match 'show_score', :to => 'users#show_score', :via => :get