From 884a201953ec0ad2380609d99078045798f3ca29 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 22 Dec 2016 13:48:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8A=A0=E5=85=A5=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=EF=BC=8C=E8=A2=AB=E5=AE=A1=E6=89=B9=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E7=AE=A1=E7=90=86=E5=91=98=E7=9A=84=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=98=BE=E7=A4=BA=E5=8A=A0=E5=85=A5=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=BA=BA=E5=A7=93=E5=90=8D=EF=BC=88=E5=B9=B6=E5=B0=86=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=BC=B9=E6=A1=86=E6=94=B9=E4=B8=BA=E6=96=B0=E7=89=88?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 42 +++++++++++-------- app/helpers/users_helper.rb | 4 +- app/views/layouts/_logined_header.html.erb | 2 +- .../members/_delete_message_tip.html.erb | 22 ++++++++++ .../members/allow_to_join_project.js.erb | 3 +- .../refused_allow_to_join_project.js.erb | 7 +++- .../_user_message_applide_action.html.erb | 26 ++++++++++-- 7 files changed, 79 insertions(+), 27 deletions(-) create mode 100644 app/views/members/_delete_message_tip.html.erb diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 5f0dbda97..c4989d724 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -57,10 +57,10 @@ class MembersController < ApplicationController @applied_message = AppliedMessage.find(params[:applied_message_id]) applied_project = @applied_message.applied user = User.find(@applied_message.applied_user_id) - project = Project.find(applied_project.project_id) - if user.member_of?(project) - @flash_message = "您已经是项目成员了" - @applied_message.update_attribute(:status, 2) + project = Project.find(applied_project.project_id) if !applied_project.nil? + if user.member_of?(project)|| AppliedMessage.where(:applied_id => @applied_message.applied_id, :status => 1).count == 0 + @flash_message = "该申请已被其他管理员处理" + # @applied_message.update_attribute(:status, 2) else ap_role = applied_project.try(:role) if ap_role @@ -104,24 +104,30 @@ class MembersController < ApplicationController @applied_message = AppliedMessage.find(params[:applied_message_id]) # @applied_message.update_attribute(:status, 3) applied_project = @applied_message.applied - project = Project.find(@applied_message.project_id) - # 发送消息给被拒者,user_id对应的收到信息的用户 - AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, + project = Project.find(@applied_message.project_id) if !applied_project.nil? + user = User.find(@applied_message.applied_user_id) + if user.member_of?(project) || AppliedMessage.where(:applied_id => @applied_message.applied_id, :status => 1).count == 0 + @flash_message = "该申请已被其他管理员处理" + # @applied_message.update_attribute(:status, 2) + else + # 发送消息给被拒者,user_id对应的收到信息的用户 + AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, :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_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, :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) - ps = ProjectsService.new - user = User.find(@applied_message.applied_user_id) - ap_role = applied_project.try(:role) - ps.send_wechat_join_project_notice user,project,ap_role,1 + 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) + ps = ProjectsService.new + user = User.find(@applied_message.applied_user_id) + ap_role = applied_project.try(:role) + ps.send_wechat_join_project_notice user,project,ap_role,1 - applied_project.delete + applied_project.delete + end end def create diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index ed504c5db..d9c8dcfac 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -145,11 +145,11 @@ module UsersHelper when 4 "被拒绝" when 5 - "您已拒绝" + "已拒绝" when 6 "已通过" when 7 - "您已同意" + "已同意" end end diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 53d161d62..193e8fd75 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -5,7 +5,7 @@