Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 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
@ -25,13 +27,12 @@ class Member < ActiveRecord::Base
validates_presence_of :principal, :project
validates_uniqueness_of :user_id, :scope => :project_id
validate :validate_role
attr_protected :id
before_destroy :set_issue_category_nil, :remove_from_project_default_assigned_to
scope :active, lambda { joins(:principal).where(:users => {:status => Principal::STATUS_ACTIVE})}
# Sort by first role and principal
# Sort by first role and principal
scope :sorted, lambda {
includes(:member_roles, :roles, :principal).
reorder("#{Role.table_name}.position").
@ -109,6 +110,16 @@ class Member < ActiveRecord::Base
member_roles.any? {|mr| mr.role_id == role.id && mr.inherited_from.present?}
end
# Returns an Array of Project and/or Group from which the given role
# was inherited, or an empty Array if the role was not inherited
def role_inheritance(role)
member_roles.
select {|mr| mr.role_id == role.id && mr.inherited_from.present?}.
map {|mr| mr.inherited_from_member_role.try(:member)}.
compact.
map {|m| m.project == project ? m.principal : m.project}
end
# Returns true if the member's role is editable by user
def role_editable?(role, user=User.current)
if has_inherited_role?(role)