comparison app/models/member.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents e248c7af89ec
children
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
71 71
72 def deletable? 72 def deletable?
73 member_roles.detect {|mr| mr.inherited_from}.nil? 73 member_roles.detect {|mr| mr.inherited_from}.nil?
74 end 74 end
75 75
76 def destroy
77 if member_roles.reload.present?
78 # destroying the last role will destroy another instance
79 # of the same Member record, #super would then trigger callbacks twice
80 member_roles.destroy_all
81 @destroyed = true
82 freeze
83 else
84 super
85 end
86 end
87
76 def include?(user) 88 def include?(user)
77 if principal.is_a?(Group) 89 if principal.is_a?(Group)
78 !user.nil? && user.groups.include?(principal) 90 !user.nil? && user.groups.include?(principal)
79 else 91 else
80 self.user == user 92 self.user == user
82 end 94 end
83 95
84 def set_issue_category_nil 96 def set_issue_category_nil
85 if user 97 if user
86 # remove category based auto assignments for this member 98 # remove category based auto assignments for this member
87 IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id] 99 IssueCategory.where(["project_id = ? AND assigned_to_id = ?", project.id, user.id]).
100 update_all("assigned_to_id = NULL")
88 end 101 end
89 end 102 end
90 103
91 # Find or initilize a Member with an id, attributes, and for a Principal 104 # Find or initilize a Member with an id, attributes, and for a Principal
92 def self.edit_membership(id, new_attributes, principal=nil) 105 def self.edit_membership(id, new_attributes, principal=nil)