diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /app/models/namespace.rb | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r-- | app/models/namespace.rb | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 51c39ad4ec3..d7d53956656 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -86,6 +86,7 @@ class Namespace < ApplicationRecord has_many :issues, inverse_of: :namespace has_many :timelog_categories, class_name: 'TimeTracking::TimelogCategory' + has_many :achievements, class_name: 'Achievements::Achievement' validates :owner, presence: true, if: ->(n) { n.owner_required? } validates :name, @@ -131,26 +132,28 @@ class Namespace < ApplicationRecord to: :namespace_settings, allow_nil: true delegate :show_diff_preview_in_email, :show_diff_preview_in_email?, :show_diff_preview_in_email=, to: :namespace_settings + delegate :runner_registration_enabled, :runner_registration_enabled?, :runner_registration_enabled=, + to: :namespace_settings delegate :maven_package_requests_forwarding, :pypi_package_requests_forwarding, :npm_package_requests_forwarding, to: :package_settings - after_save :reload_namespace_details - - after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?('share_with_group_lock') } - before_create :sync_share_with_group_lock_with_parent before_update :sync_share_with_group_lock_with_parent, if: :parent_changed? after_update :force_share_with_group_lock_on_descendants, if: -> { saved_change_to_share_with_group_lock? && share_with_group_lock? } after_update :expire_first_auto_devops_config_cache, if: -> { saved_change_to_auto_devops_enabled? } + after_update :move_dir, if: :saved_change_to_path_or_parent?, unless: -> { is_a?(Namespaces::ProjectNamespace) } + after_destroy :rm_dir + after_save :reload_namespace_details + + after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?('share_with_group_lock') } + after_sync_traversal_ids :schedule_sync_event_worker # custom callback defined in Namespaces::Traversal::Linear # Legacy Storage specific hooks - after_update :move_dir, if: :saved_change_to_path_or_parent?, unless: -> { is_a?(Namespaces::ProjectNamespace) } before_destroy(prepend: true) { prepare_for_destroy } - after_destroy :rm_dir after_commit :expire_child_caches, on: :update, if: -> { Feature.enabled?(:cached_route_lookups, self, type: :ops) && saved_change_to_name? || saved_change_to_path? || saved_change_to_parent_id? @@ -330,6 +333,13 @@ class Namespace < ApplicationRecord type.nil? || type == Namespaces::UserNamespace.sti_name || !(group_namespace? || project_namespace?) end + def bot_user_namespace? + return false unless user_namespace? + return false unless owner && owner.bot? + + true + end + def owner_required? user_namespace? end @@ -507,6 +517,10 @@ class Namespace < ApplicationRecord root? && actual_plan.paid? end + def prevent_delete? + paid? + end + def actual_limits # We default to PlanLimits.new otherwise a lot of specs would fail # On production each plan should already have associated limits record @@ -541,12 +555,10 @@ class Namespace < ApplicationRecord def shared_runners_setting if shared_runners_enabled SR_ENABLED + elsif allow_descendants_override_disabled_shared_runners + SR_DISABLED_WITH_OVERRIDE else - if allow_descendants_override_disabled_shared_runners - SR_DISABLED_WITH_OVERRIDE - else - SR_DISABLED_AND_UNOVERRIDABLE - end + SR_DISABLED_AND_UNOVERRIDABLE end end @@ -597,6 +609,10 @@ class Namespace < ApplicationRecord namespace_settings&.enabled_git_access_protocol end + def all_ancestors_have_runner_registration_enabled? + namespace_settings&.all_ancestors_have_runner_registration_enabled? + end + private def cluster_enabled_granted? |