diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/models/group.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 74f7efd253d..3509299a579 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -71,6 +71,9 @@ class Group < Namespace has_many :group_deploy_tokens has_many :deploy_tokens, through: :group_deploy_tokens + has_one :dependency_proxy_setting, class_name: 'DependencyProxy::GroupSetting' + has_many :dependency_proxy_blobs, class_name: 'DependencyProxy::Blob' + accepts_nested_attributes_for :variables, allow_destroy: true validate :visibility_level_allowed_by_projects @@ -98,6 +101,19 @@ class Group < Namespace scope :by_id, ->(groups) { where(id: groups) } + scope :for_authorized_group_members, -> (user_ids) do + joins(:group_members) + .where("members.user_id IN (?)", user_ids) + .where("access_level >= ?", Gitlab::Access::GUEST) + end + + scope :for_authorized_project_members, -> (user_ids) do + joins(projects: :project_authorizations) + .where("project_authorizations.user_id IN (?)", user_ids) + end + + delegate :default_branch_name, to: :namespace_settings + class << self def sort_by_attribute(method) if method == 'storage_size_desc' @@ -190,6 +206,10 @@ class Group < Namespace ::Gitlab.config.packages.enabled end + def dependency_proxy_feature_available? + ::Gitlab.config.dependency_proxy.enabled + end + def notification_email_for(user) # Finds the closest notification_setting with a `notification_email` notification_settings = notification_settings_for(user, hierarchy_order: :asc) @@ -571,12 +591,16 @@ class Group < Namespace ancestor_settings.allow_mfa_for_subgroups end + def has_project_with_service_desk_enabled? + Gitlab::ServiceDesk.supported? && all_projects.service_desk_enabled.exists? + end + private def update_two_factor_requirement return unless saved_change_to_require_two_factor_authentication? || saved_change_to_two_factor_grace_period? - members_with_descendants.find_each(&:update_two_factor_requirement) + direct_and_indirect_members.find_each(&:update_two_factor_requirement) end def path_changed_hook |