Fixed: all members (including non active) should be deleted when deleting a project.
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@971 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
9a5f4a83a7
commit
0c424f9de8
1 file changed
+8
-1
@@ -20,7 +20,7 @@ class Project < ActiveRecord::Base
|
|||||||
STATUS_ACTIVE = 1
|
STATUS_ACTIVE = 1
|
||||||
STATUS_ARCHIVED = 9
|
STATUS_ARCHIVED = 9
|
||||||
|
|
||||||
has_many :members, :dependent => :delete_all, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
|
has_many :members, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
|
||||||
has_many :users, :through => :members
|
has_many :users, :through => :members
|
||||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||||
has_many :enabled_modules, :dependent => :delete_all
|
has_many :enabled_modules, :dependent => :delete_all
|
||||||
@@ -62,6 +62,8 @@ class Project < ActiveRecord::Base
|
|||||||
validates_length_of :identifier, :in => 3..20
|
validates_length_of :identifier, :in => 3..20
|
||||||
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
|
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
|
||||||
|
|
||||||
|
before_destroy :delete_all_members
|
||||||
|
|
||||||
def identifier=(identifier)
|
def identifier=(identifier)
|
||||||
super unless identifier_frozen?
|
super unless identifier_frozen?
|
||||||
end
|
end
|
||||||
@@ -129,6 +131,11 @@ class Project < ActiveRecord::Base
|
|||||||
children.select {|child| child.active?}
|
children.select {|child| child.active?}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Deletes all project's members
|
||||||
|
def delete_all_members
|
||||||
|
Member.delete_all(['project_id = ?', id])
|
||||||
|
end
|
||||||
|
|
||||||
# Users issues can be assigned to
|
# Users issues can be assigned to
|
||||||
def assignable_users
|
def assignable_users
|
||||||
members.select {|m| m.role.assignable?}.collect {|m| m.user}.sort
|
members.select {|m| m.role.assignable?}.collect {|m| m.user}.sort
|
||||||
|
|||||||
Reference in new issue
Block a user