Class: Organizations::Organization
Constant Summary
collapse
- DEFAULT_ORGANIZATION_ID =
1
Gitlab::VisibilityLevel::INTERNAL, Gitlab::VisibilityLevel::LEVELS_FOR_ADMINS, Gitlab::VisibilityLevel::PRIVATE, Gitlab::VisibilityLevel::PUBLIC
Gitlab::SQL::Pattern::MIN_CHARS_FOR_PARTIAL_MATCHING, Gitlab::SQL::Pattern::REGEX_QUOTED_TERM
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
#flipper_id
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
split_query_to_search_terms
===, 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!, sharding_keys, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Class Method Details
.default?(id) ⇒ Boolean
66
67
68
|
# File 'app/models/organizations/organization.rb', line 66
def self.default?(id)
id == DEFAULT_ORGANIZATION_ID
end
|
.default_organization ⇒ Object
62
63
64
|
# File 'app/models/organizations/organization.rb', line 62
def self.default_organization
find_by(id: DEFAULT_ORGANIZATION_ID)
end
|
.search(query, use_minimum_char_limit: true) ⇒ Object
58
59
60
|
# File 'app/models/organizations/organization.rb', line 58
def self.search(query, use_minimum_char_limit: true)
fuzzy_search(query, [:name, :path], use_minimum_char_limit: use_minimum_char_limit)
end
|
Instance Method Details
#add_owner(user) ⇒ Object
102
103
104
|
# File 'app/models/organizations/organization.rb', line 102
def add_owner(user)
organization_users.owners.create(user: user)
end
|
#default? ⇒ Boolean
79
80
81
|
# File 'app/models/organizations/organization.rb', line 79
def default?
self.class.default?(id)
end
|
#full_path ⇒ Object
121
122
123
124
125
|
# File 'app/models/organizations/organization.rb', line 121
def full_path
return '' unless scoped_paths?
"/o/#{path}"
end
|
#inspect ⇒ Object
117
118
119
|
# File 'app/models/organizations/organization.rb', line 117
def inspect
"#<#{self.class.name} id:#{id} path:#{path}>"
end
|
#organization_detail ⇒ Object
75
76
77
|
# File 'app/models/organizations/organization.rb', line 75
def organization_detail
super.presence || build_organization_detail
end
|
#owner?(user) ⇒ Boolean
98
99
100
|
# File 'app/models/organizations/organization.rb', line 98
def owner?(user)
organization_users.owners.exists?(user: user)
end
|
#owner_user_ids ⇒ Object
87
88
89
90
91
|
# File 'app/models/organizations/organization.rb', line 87
def owner_user_ids
organization_users.owners.pluck(:user_id)
end
|
#scoped_paths? ⇒ Boolean
For example: scoped path - /o/my-org/my-group/my-project unscoped path - /my-group/my-project
113
114
115
|
# File 'app/models/organizations/organization.rb', line 113
def scoped_paths?
Feature.enabled?(:organization_scoped_paths, self) && !default?
end
|
#to_param ⇒ Object
83
84
85
|
# File 'app/models/organizations/organization.rb', line 83
def to_param
path
end
|
#user?(user) ⇒ Boolean
94
95
96
|
# File 'app/models/organizations/organization.rb', line 94
def user?(user)
organization_users.exists?(user: user)
end
|
#visibility_level_field ⇒ Object
Required for Gitlab::VisibilityLevel module
71
72
73
|
# File 'app/models/organizations/organization.rb', line 71
def visibility_level_field
:visibility_level
end
|
#web_url(only_path: nil) ⇒ Object
106
107
108
|
# File 'app/models/organizations/organization.rb', line 106
def web_url(only_path: nil)
Gitlab::UrlBuilder.build(self, only_path: only_path)
end
|