summaryrefslogtreecommitdiffstats
path: root/app/models/group.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-23 18:18:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-23 18:18:13 +0000
commit578fdc62f26c23951b2d2c2b9be0040c7ade0634 (patch)
tree7f78426f78bdc325cae50368cc1bc3e23f4c5eaa /app/models/group.rb
parente1832f25c9aa16f1a95434adc209ee937110228a (diff)
downloadredmine-578fdc62f26c23951b2d2c2b9be0040c7ade0634.tar.gz
redmine-578fdc62f26c23951b2d2c2b9be0040c7ade0634.zip
Ability to assign issues to groups (#2964).
Option is disabled by default. It can be turned on in application settings. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6306 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/group.rb')
-rw-r--r--app/models/group.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 1b55c2566..f3721f7fd 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -1,5 +1,5 @@
# Redmine - project management software
-# Copyright (C) 2006-2009 Jean-Philippe Lang
+# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -24,11 +24,15 @@ class Group < Principal
validates_presence_of :lastname
validates_uniqueness_of :lastname, :case_sensitive => false
validates_length_of :lastname, :maximum => 30
-
+
+ before_destroy :remove_references_before_destroy
+
def to_s
lastname.to_s
end
+ alias :name :to_s
+
def user_added(user)
members.each do |member|
next if member.project.nil?
@@ -46,4 +50,13 @@ class Group < Principal
:conditions => ["#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids]).each(&:destroy)
end
end
+
+ private
+
+ # Removes references that are not handled by associations
+ def remove_references_before_destroy
+ return if self.id.nil?
+
+ Issue.update_all 'assigned_to_id = NULL', ['assigned_to_id = ?', id]
+ end
end