Class: Namespaces::UserNamespace
- Inherits:
-
Namespace
- Object
- ActiveRecord::Base
- ApplicationRecord
- Namespace
- Namespaces::UserNamespace
- Defined in:
- app/models/namespaces/user_namespace.rb
Overview
PLEASE DO NOT OVERRIDE METHODS IN THIS CLASS!
This class is a placeholder for STI. But we also want to ensure tests using :namespace factory are still testing the same functionality.
Many legacy tests use :namespace which has a slight semantic mismatch as it always has been a User (personal) namespace.
If you need to make a change here, please ping the Tenant Scale group so we can ensure that the changes do not break existing functionality.
As Namespaces evolve we may be able to relax this restriction but for now, please check in with us <3
For details, see the discussion in gitlab.com/gitlab-org/gitlab/-/merge_requests/74152
Constant Summary
Constants inherited from Namespace
Namespace::NUMBER_OF_ANCESTORS_ALLOWED, Namespace::SHARED_RUNNERS_SETTINGS, Namespace::SR_DISABLED_AND_OVERRIDABLE, Namespace::SR_DISABLED_AND_UNOVERRIDABLE, Namespace::SR_ENABLED, Namespace::STATISTICS_COLUMNS, Namespace::URL_MAX_LENGTH
Constants included from Cells::Claimable
Cells::Claimable::CLAIMS_BUCKET_TYPE, Cells::Claimable::CLAIMS_SOURCE_TYPE, Cells::Claimable::CLAIMS_SUBJECT_TYPE, Cells::Claimable::MissingPrimaryKeyError
Constants included from BlocksUnsafeSerialization
BlocksUnsafeSerialization::UnsafeSerializationError
Constants included from Stateful
Constants included from Traversal::Linear
Traversal::Linear::UnboundedSearch
Constants included from Gitlab::SQL::Pattern
Gitlab::SQL::Pattern::MIN_CHARS_FOR_PARTIAL_MATCHING, Gitlab::SQL::Pattern::REGEX_QUOTED_TERM
Constants included from Gitlab::VisibilityLevel
Gitlab::VisibilityLevel::INTERNAL, Gitlab::VisibilityLevel::LEVELS_FOR_ADMINS, Gitlab::VisibilityLevel::PRIVATE, Gitlab::VisibilityLevel::PUBLIC
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Instance Attribute Summary
Attributes inherited from Namespace
#emails_enabled_memoized, #root_ancestor
Class Method Summary collapse
Instance Method Summary collapse
- #crm_group ⇒ Object
-
#max_member_access_for_user(user, only_concrete_membership: false) ⇒ Object
Return the highest access level for a user.
- #member?(user, min_access_level = Gitlab::Access::GUEST) ⇒ Boolean
- #owner_entity ⇒ Object
- #owners ⇒ Object
Methods inherited from Namespace
#actual_limits, #actual_plan, #actual_plan_name, #aggregation_scheduled?, #all_active_project_ids, #all_ancestors_have_runner_registration_enabled?, #all_catalog_resources, #all_container_repositories, #all_project_ids_except, #all_projects, #all_projects_except_soft_deleted, #all_projects_with_pages, #allow_runner_registration_token?, #allowed_work_item_type?, #allowed_work_item_types, #ancestors_archived?, #any_project_has_container_registry_tags?, #any_project_with_pages_deployed?, #any_project_with_shared_runners_enabled?, #archived?, #auto_devops_enabled?, #bot_user_namespace?, by_path, #certificate_based_clusters_enabled?, #changing_allow_descendants_override_disabled_shared_runners_is_allowed, #changing_shared_runners_enabled_is_allowed, clean_path, #closest_setting, #container_repositories_size, #container_repositories_size_cache_key, #default_branch_protected?, #default_branch_protection, #default_branch_protection_settings, #emails_disabled?, #emails_enabled?, #enabled_git_access_protocol, #feature_available?, find_by_path_or_name, #find_fork_of, find_top_level, #first_auto_devops_config, #first_owner, #first_project_with_container_registry_tags, #full_path_before_last_save, gfm_autocomplete_search, #group_namespace?, #has_parent?, #human_name, #issue_repositioning_disabled?, #kind, #lfs_enabled?, #licensed_feature_available?, #linked_to_subscription?, #multiple_issue_boards_available?, #namespace_details, #owner_entity_name, #owner_required?, #package_settings, #pages_access_control_forced_by_ancestor?, #pages_access_control_forced_by_self_or_ancestor?, #pages_access_control_trie, #paid?, #pipeline_variables_default_role, #project_namespace?, #recent?, reference_pattern, reference_prefix, #refresh_project_authorizations, #root?, root_ids_for, search, #self_deletion_in_progress?, #self_or_ancestors_archived?, self_or_ancestors_archived_setting_subquery, #send_update_instructions, #shared_runners, #shared_runners_setting, #shared_runners_setting_higher_than?, sti_class_for, #subgroup?, sum_project_statistics_column, #supports_work_items?, #to_param, #to_reference, #to_reference_base, #traversal_ids_as_sql, #uploads_sharding_key, #user_ids_for_project_authorizations, #user_namespace?, #user_role, username_reserved?, username_reserved_for_organization?, #visibility_level_field, #web_url
Methods included from Gitlab::Utils::Override
#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!
Methods included from Cells::Claimable
Methods included from Referable
#referable_inspect, #reference_link_text, #to_reference, #to_reference_base
Methods included from Ci::NamespaceSettings
#allow_stale_runner_pruning=, #allow_stale_runner_pruning?
Methods included from BlocksUnsafeSerialization
Methods included from Organizations::Isolatable
#isolated?, #mark_as_isolated!, #mark_as_not_isolated!, #not_isolated?
Methods included from AdjournedDeletable
#ancestor_scheduled_for_deletion?, #deletion_adjourned_period, #deletion_in_progress_or_scheduled_in_hierarchy_chain?, #first_scheduled_for_deletion_in_hierarchy_chain, #scheduled_for_deletion_in_hierarchy_chain?, #self_deletion_in_progress?, #self_deletion_scheduled?, #self_deletion_scheduled_deletion_created_on
Methods included from Traversal::Cached
#all_project_ids, #all_unarchived_project_ids, #descendant_ids, #self_and_descendant_ids
Methods included from Traversal::Linear
#all_project_ids, #ancestor_ids, #ancestors, #ancestors_upto, #descendants, #parent=, #parent_id=, #root_ancestor, #self_and_ancestor_ids, #self_and_ancestors, #self_and_descendant_ids, #self_and_descendants, #self_and_hierarchy, #traversal_path, #use_traversal_ids?
Methods included from Traversal::Recursive
#all_project_ids, #all_unarchived_project_ids, #ancestor_ids, #ancestors, #ancestors_upto, #descendants, #object_hierarchy, #root_ancestor, #self_and_ancestor_ids, #self_and_ancestors, #self_and_descendant_ids, #self_and_descendants, #self_and_hierarchy
Methods included from FeatureGate
Methods included from Gitlab::SQL::Pattern
Methods included from AfterCommitQueue
#run_after_commit, #run_after_commit_or_now
Methods included from Routable
#build_full_path, find_by_full_path, #full_name, #full_path, #full_path_components, #owned_by?
Methods included from Gitlab::VisibilityLevel
allowed_for?, allowed_level?, allowed_levels, allowed_levels_for_user, closest_allowed_level, #internal?, level_name, level_value, levels_for_user, non_restricted_level?, options, #private?, #public?, public_visibility_restricted?, restricted_level?, string_level, string_options, string_values, valid_level?, #visibility, #visibility=, #visibility_attribute_present?, #visibility_attribute_value, #visibility_level_attributes, #visibility_level_previous_changes, #visibility_level_value
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from Organizations::Sharding
Methods included from ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Class Method Details
.sti_name ⇒ Object
27 28 29 |
# File 'app/models/namespaces/user_namespace.rb', line 27 def self.sti_name 'User' end |
Instance Method Details
#crm_group ⇒ Object
64 65 66 |
# File 'app/models/namespaces/user_namespace.rb', line 64 def crm_group nil end |
#max_member_access_for_user(user, only_concrete_membership: false) ⇒ Object
Return the highest access level for a user
A special case is handled here when the user is a GitLab admin which implies it has “OWNER” access everywhere, but should not officially appear as a member unless specifically added to it
54 55 56 57 58 59 60 61 62 |
# File 'app/models/namespaces/user_namespace.rb', line 54 def max_member_access_for_user(user, only_concrete_membership: false) return Gitlab::Access::NO_ACCESS unless user if !only_concrete_membership && (user.can_admin_all_resources? || user.can_admin_organization?(organization)) return Gitlab::Access::OWNER end owner == user ? Gitlab::Access::OWNER : Gitlab::Access::NO_ACCESS end |
#member?(user, min_access_level = Gitlab::Access::GUEST) ⇒ Boolean
40 41 42 43 44 |
# File 'app/models/namespaces/user_namespace.rb', line 40 def member?(user, min_access_level = Gitlab::Access::GUEST) return false unless user max_member_access_for_user(user) >= min_access_level end |
#owner_entity ⇒ Object
32 33 34 |
# File 'app/models/namespaces/user_namespace.rb', line 32 def owner_entity owner end |
#owners ⇒ Object
36 37 38 |
# File 'app/models/namespaces/user_namespace.rb', line 36 def owners Array.wrap(owner) end |