Class: Group
- Includes:
- Redmine::SafeAttributes
- Defined in:
- app/models/group.rb
Overview
Redmine - project management software Copyright (C) 2006-2017 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 as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Direct Known Subclasses
Constant Summary
Constants inherited from Principal
Principal::STATUS_ACTIVE, Principal::STATUS_ANONYMOUS, Principal::STATUS_LOCKED, Principal::STATUS_REGISTERED
Class Method Summary collapse
Instance Method Summary collapse
-
#builtin? ⇒ Boolean
Return true if the group is a builtin group.
- #builtin_type ⇒ Object
-
#givable? ⇒ Boolean
Returns true if the group can be given to a user.
- #name ⇒ Object
- #name=(arg) ⇒ Object
- #to_s ⇒ Object
- #user_added(user) ⇒ Object
- #user_removed(user) ⇒ Object
Methods included from Redmine::SafeAttributes
#delete_unsafe_attributes, #safe_attribute?, #safe_attribute_names, #safe_attributes=
Methods inherited from Principal
#<=>, detect_by_keyword, fields_for_order_statement, #mail, #mail=, #member_of?, #nullify_projects_default_assigned_to, #project_ids, #reload, #visible?
Class Method Details
.anonymous ⇒ Object
100 101 102 |
# File 'app/models/group.rb', line 100 def self.anonymous GroupAnonymous.load_instance end |
.human_attribute_name(attribute_key_name, *args) ⇒ Object
92 93 94 95 96 97 98 |
# File 'app/models/group.rb', line 92 def self.human_attribute_name(attribute_key_name, *args) attr_name = attribute_key_name.to_s if attr_name == 'lastname' attr_name = "name" end super(attr_name, *args) end |
.non_member ⇒ Object
104 105 106 |
# File 'app/models/group.rb', line 104 def self.non_member GroupNonMember.load_instance end |
Instance Method Details
#builtin? ⇒ Boolean
Return true if the group is a builtin group
63 64 65 |
# File 'app/models/group.rb', line 63 def builtin? false end |
#builtin_type ⇒ Object
58 59 60 |
# File 'app/models/group.rb', line 58 def builtin_type nil end |
#givable? ⇒ Boolean
Returns true if the group can be given to a user
68 69 70 |
# File 'app/models/group.rb', line 68 def givable? !builtin? end |
#name ⇒ Object
50 51 52 |
# File 'app/models/group.rb', line 50 def name lastname end |
#name=(arg) ⇒ Object
54 55 56 |
# File 'app/models/group.rb', line 54 def name=(arg) self.lastname = arg end |
#to_s ⇒ Object
46 47 48 |
# File 'app/models/group.rb', line 46 def to_s name.to_s end |
#user_added(user) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'app/models/group.rb', line 72 def user_added(user) members.each do |member| next if member.project.nil? user_member = Member.find_by_project_id_and_user_id(member.project_id, user.id) || Member.new(:project_id => member.project_id, :user_id => user.id) member.member_roles.each do |member_role| user_member.member_roles << MemberRole.new(:role => member_role.role, :inherited_from => member_role.id) end user_member.save! end end |
#user_removed(user) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'app/models/group.rb', line 83 def user_removed(user) members.each do |member| MemberRole. joins(:member). where("#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids). each(&:destroy) end end |