Merge pull request #1779 from netfighter/feature/14377_align_copy_project_with_dtag_privacy_guidelines

pull/1796/head
Hagen Schink 10 years ago
commit b0fcd9067b
  1. 2
      app/models/project.rb
  2. 10
      app/models/project/copy.rb

@ -587,7 +587,7 @@ class Project < ActiveRecord::Base
def delete_all_members def delete_all_members
me, mr = Member.table_name, MemberRole.table_name me, mr = Member.table_name, MemberRole.table_name
connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.project_id = #{id})") connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.project_id = #{id})")
Member.delete_all(['project_id = ?', id]) Member.destroy_all(['project_id = ?', id])
end end
def destroy_all_work_packages def destroy_all_work_packages

@ -209,7 +209,7 @@ module Project::Copy
end end
end end
# Copies members from +project+ # Copies members from +project+
def copy_members(project) def copy_members(project)
# Copy users first, then groups to handle members with inherited and given roles # Copy users first, then groups to handle members with inherited and given roles
members_to_copy = [] members_to_copy = []
@ -224,9 +224,15 @@ module Project::Copy
next if role_ids.empty? next if role_ids.empty?
new_member.role_ids = role_ids new_member.role_ids = role_ids
new_member.project = self new_member.project = self
Redmine::Hook.call_hook(:copy_project_add_member, new_member: new_member, member: member)
self.memberships << new_member self.memberships << new_member
end end
# Update the omitted attributes for the copied memberships
self.memberships.each do |new_member|
member = project.memberships.find_by_user_id(new_member.user_id)
Redmine::Hook.call_hook(:copy_project_add_member, new_member: new_member, member: member)
new_member.save
end
end end
# Copies queries from +project+ # Copies queries from +project+

Loading…
Cancel
Save