项目成员编辑 添加事务
This commit is contained in:
parent
05d10e20d1
commit
7faddc30c5
|
@ -301,26 +301,29 @@ class MembersController < ApplicationController
|
||||||
#增加对课程成员修改的支持
|
#增加对课程成员修改的支持
|
||||||
if @project
|
if @project
|
||||||
if params[:membership]
|
if params[:membership]
|
||||||
@member.role_ids = params[:membership][:role_ids]
|
ActiveRecord::Base.transaction do
|
||||||
|
begin
|
||||||
#added by nie
|
@member.role_ids = params[:membership][:role_ids]
|
||||||
if (params[:membership][:role_ids])
|
if (params[:membership][:role_ids])
|
||||||
role = Role.find(params[:membership][:role_ids][0])
|
role = Role.find(params[:membership][:role_ids][0])
|
||||||
if role.allowed_to?(:is_manager)
|
if role.allowed_to?(:is_manager)
|
||||||
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
||||||
@projectInfo.save
|
@projectInfo.save
|
||||||
else
|
else
|
||||||
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||||
if user_admin.size > 0
|
if user_admin.size > 0
|
||||||
user_admin.each do |user|
|
user_admin.each do |user|
|
||||||
user.destroy
|
user.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@member.save!
|
||||||
|
rescue Exception => e
|
||||||
|
puts e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
saved = @member.save
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to_settings_in_projects }
|
format.html { redirect_to_settings_in_projects }
|
||||||
format.js
|
format.js
|
||||||
|
|
Loading…
Reference in New Issue