Class: Namespaces::ProjectNamespace
- Inherits:
-
Namespace
- Object
- ActiveRecord::Base
- ApplicationRecord
- Namespace
- Namespaces::ProjectNamespace
- Defined in:
- app/models/namespaces/project_namespace.rb
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 BlocksUnsafeSerialization
BlocksUnsafeSerialization::UnsafeSerializationError
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::PRIVATE, Gitlab::VisibilityLevel::PUBLIC
Constants included from CacheMarkdownField
CacheMarkdownField::INVALIDATED_BY
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
Attributes included from CacheMarkdownField
#skip_markdown_cache_validation
Class Method Summary collapse
Instance Method Summary collapse
-
#all_projects ⇒ Object
It’s always 1 project but it has to be an AR relation.
- #sync_attributes_from_project(project) ⇒ Object
Methods inherited from Namespace
#actual_limits, #actual_plan, #actual_plan_name, #aggregation_scheduled?, #all_ancestors_have_runner_registration_enabled?, #all_catalog_resources, #all_container_repositories, #all_project_ids_except, #all_projects_except_soft_deleted, #all_projects_with_pages, #allow_runner_registration_token?, #any_project_has_container_registry_tags?, #any_project_with_pages_deployed?, #any_project_with_shared_runners_enabled?, #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_name, clean_path, #closest_setting, #container_repositories_size, #container_repositories_size_cache_key, #default_branch_protected?, #default_branch_protection, #default_branch_protection_settings, #deleted?, #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?, #owner_required?, #package_settings, #paid?, #project_namespace?, #recent?, reference_pattern, reference_prefix, #refresh_project_authorizations, #root?, search, #send_update_instructions, #service_desk_alias_address, #shared_runners, #shared_runners_setting, #shared_runners_setting_higher_than?, sti_class_for, #subgroup?, sum_project_statistics_column, #to_param, #to_reference, #to_reference_base, #uploads_sharding_key, #user_ids_for_project_authorizations, #user_namespace?, username_reserved?, #visibility_level_field, #web_url
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 Gitlab::Utils::Override
#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!
Methods included from Traversal::Cached
#all_project_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_ids, #traversal_ids=, #traversal_path, #use_traversal_ids?
Methods included from Traversal::Recursive
#all_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?, #parent_loaded?, #route_loaded?
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 included from CacheMarkdownField
#attribute_invalidated?, #banzai_render_context, #cached_html_for, #cached_html_up_to_date?, #can_cache_field?, #invalidated_markdown_cache?, #latest_cached_markdown_version, #mentionable_attributes_changed?, #mentioned_filtered_user_ids_for, #parent_user, #refresh_markdown_cache, #refresh_markdown_cache!, #rendered_field_content, #skip_project_check?, #store_mentions!, #store_mentions_after_commit?, #updated_cached_html_for
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, 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 ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Class Method Details
.create_from_project!(project) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'app/models/namespaces/project_namespace.rb', line 28 def self.create_from_project!(project) return unless project.new_record? return unless project.namespace proj_namespace = project.project_namespace || project.build_project_namespace project.project_namespace.sync_attributes_from_project(project) proj_namespace.save! proj_namespace end |
.polymorphic_name ⇒ Object
24 25 26 |
# File 'app/models/namespaces/project_namespace.rb', line 24 def self.polymorphic_name 'Namespaces::ProjectNamespace' end |
.sti_name ⇒ Object
20 21 22 |
# File 'app/models/namespaces/project_namespace.rb', line 20 def self.sti_name 'Project' end |
Instance Method Details
#all_projects ⇒ Object
It’s always 1 project but it has to be an AR relation
66 67 68 |
# File 'app/models/namespaces/project_namespace.rb', line 66 def all_projects Project.where(id: project.id) end |
#sync_attributes_from_project(project) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/namespaces/project_namespace.rb', line 38 def sync_attributes_from_project(project) attribute_list = %w[name path namespace_id namespace visibility_level shared_runners_enabled organization_id] attributes_to_sync = project .changes .slice(*attribute_list) .transform_values { |val| val[1] } # if visibility_level is not set explicitly for project, it defaults to 0, # but for namespace visibility_level defaults to 20, # so it gets out of sync right away if we do not set it explicitly when creating the project namespace attributes_to_sync['visibility_level'] ||= project.visibility_level if project.new_record? # when a project is associated with a group while the group is created we need to ensure we associate the new # group with the project namespace as well. # E.g. # project = create(:project) <- project is saved # create(:group, projects: [project]) <- associate project with a group that is not yet created. if attributes_to_sync.has_key?('namespace_id') && attributes_to_sync['namespace_id'].blank? && project.namespace.present? attributes_to_sync['parent'] = project.namespace end assign_attributes(attributes_to_sync) end |