From 7658844a28061da611ef4f2ae3e29f21c5087a5e Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 2 Aug 2016 14:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=BB=8F=E8=BF=87=E5=BC=B9?= =?UTF-8?q?=E6=A1=86=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 8 +++--- app/helpers/users_helper.rb | 25 +++++++++++++++++++ .../layouts/_show_messages_list.html.erb | 7 ++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 9cac4de3d..f14416442 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -79,7 +79,7 @@ class MembersController < ApplicationController # 添加成功后所有管理员收到的消息状态都要更新 applied_messages = AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 1, :applied_type => "AppliedProject") - applied_messages.update_all(:status => 7) + applied_messages.update_all(:status => 7, :viewed => true) @applied_message = AppliedMessage.find(params[:applied_message_id]) # 添加成功后,申请人收到消息 AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id , @@ -105,12 +105,12 @@ class MembersController < ApplicationController applied_project = @applied_message.applied # 发送消息给被拒者,user_id对应的收到信息的用户 AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, - :viewed => true, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id) + :viewed => false, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id) # 拒绝功后所有管理员收到的消息状态都要更新 applied_messages = AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 1, - :applied_type => "AppliedProject") - applied_messages.update_all(:status => 5) + :applied_type => "AppliedProject") + applied_messages.update_all(:status => 5, :viewed => true) @applied_message = AppliedMessage.find(params[:applied_message_id]) # AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, # :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 91743289a..1bb76b6fd 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -80,6 +80,19 @@ module UsersHelper # end end + def applied_project_status applied_message + case applied_message.status + when 4 + "被拒绝" + when 5 + "您已拒绝" + when 6 + "已通过" + when 7 + "您已同意" + end + end + # 项目申请消息通过状态判断tip描述 def applied_project_tip applied_message case applied_message.status @@ -92,6 +105,18 @@ module UsersHelper end end + def applied_project_tip_header applied_message + case applied_message.status + when 4 + "婉拒您" + when 5,3,2,1,7 + "申请:" + when 6 + "同意您" + end + end + + def get_resource_origin attach type = attach.container_type content = attach.container diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb index 0829b9c42..a30d86d07 100644 --- a/app/views/layouts/_show_messages_list.html.erb +++ b/app/views/layouts/_show_messages_list.html.erb @@ -88,6 +88,13 @@ <% elsif ma.course_message_type == "Exercise" && ma.status == 3 %>
  • <%=ma.course_message.user.show_name %>老师 发布的测验:<%=ma.course_message.exercise_name %> 截止时间快到了
  • <% end %> + <% elsif ma.class == AppliedMessage %> + <% if ma.applied_type == "AppliedProject" %> +
  • <%=link_to "#{applied_project_users(ma)}".html_safe, user_path(applied_project_users(ma)), :target => '_blank' %> + <%= applied_project_tip_header(ma) %>以“<%= applied_project_message_type(ma.role) %>”身份加入<% project = Project.find(ma.project_id) %> + <%= link_to project.name, project_path(ma.project_id), :class => "link-blue", :target => '_blank', :title => "#{project.name}" %> + + <% end %> <% elsif ma.class == ForgeMessage %> <% if ma.forge_message_type == "AppliedProject" %>
  • " target="_blank" title="<%=ma.forge_message.user.show_name %> 申请加入项目:<%= ma.project.name%>"><%=ma.forge_message.user.show_name %> 申请加入项目:<%= ma.project.name%>