同意加入消息发送,及添加成员

This commit is contained in:
huang 2016-07-29 15:58:24 +08:00
parent c07677ef99
commit 450217e7c2
4 changed files with 18 additions and 21 deletions

View File

@ -55,7 +55,7 @@ class AppliedProjectController < ApplicationController
@flag = 3
else
@flag = 4
role = params[:member] == "member_manager" ? 4 : (params[:member] = "member_developer" ? 5 : 6)
role = params[:member] == "member_manager" ? 3 : (params[:member] = "member_developer" ? 4 :5)
applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role)
# 申请成功则给项目管理员发送邮件及发送消息
Mailer.run.applied_project(applied_project)

View File

@ -58,9 +58,6 @@ class MembersController < ApplicationController
applied_project = @applied_message.applied
user = User.find(@applied_message.applied_user_id)
project = Project.find(applied_project.project_id)
# applied_project = AppliedProject.where(:project_id => params[:project_id], :user_id => params[:user_id]).first
# @applied_message = AppliedMessage.find(params[:applied_id])
if user.member_of?(project)
@flash_message = "您已经是项目成员了"
@applied_message.update_attribute(:status, 2)
@ -71,17 +68,18 @@ class MembersController < ApplicationController
members = []
user_grades = []
project_info = []
members << Member.new(:role_ids => ["#{ap_role}"], :user_id => params[:user_id])
user_grades << UserGrade.new(:user_id => params[:user_id], :project_id => params[:project_id])
members << Member.new(:role_ids => ["#{ap_role}"], :user_id => @applied_message.applied_user_id)
user_grades << UserGrade.new(:user_id => @applied_message.applied_user_id, :project_id => project.id)
role = Role.find(ap_role)
project_info << ProjectInfo.new(:project_id => params[:project_id], :user_id => params[:user_id]) if role.allowed_to?(:is_manager)
project_info << ProjectInfo.new(:project_id => project.id, :user_id => @applied_message.applied_user_id) if role.allowed_to?(:is_manager)
project.members << members
project.project_infos << project_info
project.user_grades << user_grades unless user_grades.first.user_id.nil?
@applied_message.update_attribute(:status, 2)
# 添加成功后,申请人收到消息
AppliedMessage.create(:user_id => params[:send_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => params[:user_id])
AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => @applied_message.user_id)
# 添加成功后,批准人收到消息
AppliedMessage.create(:user_id => params[:user_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => params[:send_id])
AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id)
rescue Exception => e
puts e
end
@ -101,6 +99,7 @@ class MembersController < ApplicationController
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)
# 发送消息给拒绝者
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)
# applied_project.delete
end
def create

View File

@ -57,11 +57,11 @@ module UsersHelper
# 获取消息角色
def applied_project_message_type role
case role
when 4
when 3
"管理员"
when 5
when 4
"开发人员"
when 6
when 5
"报告人员"
end
end
@ -74,13 +74,10 @@ module UsersHelper
# 项目申请消息通过状态判断用户
# status(1申请的消息2已操作过该消息包括同意或者拒绝消息状态更新3拒绝消息4:被拒人收到消息5拒绝者收到消息6同意后申请人收到消息7同意后批准人收到消息)
def applied_project_users applied_message
case applied_message.status
when 3,2,1,5,4
user = User.find(applied_message.applied_user_id)
when 6
user = User.find(applied_message.user_id)
end
# case applied_message.status
# when 3,2,1,5,4,7,6
user = User.find(applied_message.applied_user_id)
# end
end
# 项目申请消息通过状态判断tip描述
@ -88,8 +85,10 @@ module UsersHelper
case applied_message.status
when 4
"拒绝申请加入项目:"
when 5,3,2,1
when 5,3,2,1,7
"申请加入项目:"
when 6
"同意申请加入项目"
end
end

View File

@ -3,4 +3,3 @@
<% else%>
$("#applied_project_<%= @applied_message.id %>").html('<%= render :partial => "users/user_message_applide_action", :locals =>{:ma => @applied_message} %>');
<% end%>