diff options
author | Mario de la Ossa <mdelaossa@gitlab.com> | 2018-02-02 21:39:55 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-02-02 21:39:55 +0300 |
commit | eaada9d7066a20b5af815f723e09cde60a5c8c10 (patch) | |
tree | 72ba4231e28f1c5e5405db21e0611a55e6428145 /app/models | |
parent | 8fa2932dc5cc7687e7d85ae7b00c07fd9bcc24a4 (diff) |
use Gitlab::UserSettings directly as a singleton instead of including/extending it
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/clusters/platforms/kubernetes.rb | 3 | ||||
-rw-r--r-- | app/models/issue_assignee.rb | 2 | ||||
-rw-r--r-- | app/models/key.rb | 5 | ||||
-rw-r--r-- | app/models/namespace.rb | 1 | ||||
-rw-r--r-- | app/models/note.rb | 3 | ||||
-rw-r--r-- | app/models/project.rb | 18 | ||||
-rw-r--r-- | app/models/project_services/kubernetes_service.rb | 3 | ||||
-rw-r--r-- | app/models/protected_branch.rb | 6 | ||||
-rw-r--r-- | app/models/snippet.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 18 |
10 files changed, 24 insertions, 39 deletions
diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index 9160a169452..7f38dcc4a9c 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -1,7 +1,6 @@ module Clusters module Platforms class Kubernetes < ActiveRecord::Base - include Gitlab::CurrentSettings include Gitlab::Kubernetes include ReactiveCaching @@ -169,7 +168,7 @@ module Clusters { token: token, ca_pem: ca_pem, - max_session_time: current_application_settings.terminal_max_session_time + max_session_time: Gitlab::CurrentSettings.terminal_max_session_time } end diff --git a/app/models/issue_assignee.rb b/app/models/issue_assignee.rb index 06d760b6a89..326b9eb7ad5 100644 --- a/app/models/issue_assignee.rb +++ b/app/models/issue_assignee.rb @@ -1,6 +1,4 @@ class IssueAssignee < ActiveRecord::Base - extend Gitlab::CurrentSettings - belongs_to :issue belongs_to :assignee, class_name: "User", foreign_key: :user_id end diff --git a/app/models/key.rb b/app/models/key.rb index a3f8a5d6dc7..7406c98c99e 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -1,7 +1,6 @@ require 'digest/md5' class Key < ActiveRecord::Base - include Gitlab::CurrentSettings include AfterCommitQueue include Sortable @@ -104,7 +103,7 @@ class Key < ActiveRecord::Base end def key_meets_restrictions - restriction = current_application_settings.key_restriction_for(public_key.type) + restriction = Gitlab::CurrentSettings.key_restriction_for(public_key.type) if restriction == ApplicationSetting::FORBIDDEN_KEY_VALUE errors.add(:key, forbidden_key_type_message) @@ -115,7 +114,7 @@ class Key < ActiveRecord::Base def forbidden_key_type_message allowed_types = - current_application_settings + Gitlab::CurrentSettings .allowed_key_types .map(&:upcase) .to_sentence(last_word_connector: ', or ', two_words_connector: ' or ') diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 37a7417cafc..5010dd73c11 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -2,7 +2,6 @@ class Namespace < ActiveRecord::Base include CacheMarkdownField include Sortable include Gitlab::ShellAdapter - include Gitlab::CurrentSettings include Gitlab::VisibilityLevel include Routable include AfterCommitQueue diff --git a/app/models/note.rb b/app/models/note.rb index a84db8982e5..01a778a7424 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -3,7 +3,6 @@ # A note of this type is never resolvable. class Note < ActiveRecord::Base extend ActiveModel::Naming - include Gitlab::CurrentSettings include Participable include Mentionable include Awardable @@ -196,7 +195,7 @@ class Note < ActiveRecord::Base end def max_attachment_size - current_application_settings.max_attachment_size.megabytes.to_i + Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i end def hook_attrs diff --git a/app/models/project.rb b/app/models/project.rb index 90f5df6265d..03c5475c31f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -4,7 +4,6 @@ class Project < ActiveRecord::Base include Gitlab::ConfigHelper include Gitlab::ShellAdapter include Gitlab::VisibilityLevel - include Gitlab::CurrentSettings include AccessRequestable include Avatarable include CacheMarkdownField @@ -23,7 +22,6 @@ class Project < ActiveRecord::Base include ::Gitlab::Utils::StrongMemoize extend Gitlab::ConfigHelper - extend Gitlab::CurrentSettings BoardLimitExceeded = Class.new(StandardError) @@ -51,8 +49,8 @@ class Project < ActiveRecord::Base default_value_for :visibility_level, gitlab_config_features.visibility_level default_value_for :resolve_outdated_diff_discussions, false default_value_for :container_registry_enabled, gitlab_config_features.container_registry - default_value_for(:repository_storage) { current_application_settings.pick_repository_storage } - default_value_for(:shared_runners_enabled) { current_application_settings.shared_runners_enabled } + default_value_for(:repository_storage) { Gitlab::CurrentSettings.pick_repository_storage } + default_value_for(:shared_runners_enabled) { Gitlab::CurrentSettings.shared_runners_enabled } default_value_for :issues_enabled, gitlab_config_features.issues default_value_for :merge_requests_enabled, gitlab_config_features.merge_requests default_value_for :builds_enabled, gitlab_config_features.builds @@ -486,14 +484,14 @@ class Project < ActiveRecord::Base def auto_devops_enabled? if auto_devops&.enabled.nil? - current_application_settings.auto_devops_enabled? + Gitlab::CurrentSettings.auto_devops_enabled? else auto_devops.enabled? end end def has_auto_devops_implicitly_disabled? - auto_devops&.enabled.nil? && !current_application_settings.auto_devops_enabled? + auto_devops&.enabled.nil? && !Gitlab::CurrentSettings.auto_devops_enabled? end def empty_repo? @@ -1471,14 +1469,14 @@ class Project < ActiveRecord::Base # Ensure HEAD points to the default branch in case it is not master change_head(default_branch) - if current_application_settings.default_branch_protection != Gitlab::Access::PROTECTION_NONE && !ProtectedBranch.protected?(self, default_branch) + if Gitlab::CurrentSettings.default_branch_protection != Gitlab::Access::PROTECTION_NONE && !ProtectedBranch.protected?(self, default_branch) params = { name: default_branch, push_access_levels_attributes: [{ - access_level: current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_PUSH ? Gitlab::Access::DEVELOPER : Gitlab::Access::MASTER + access_level: Gitlab::CurrentSettings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_PUSH ? Gitlab::Access::DEVELOPER : Gitlab::Access::MASTER }], merge_access_levels_attributes: [{ - access_level: current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE ? Gitlab::Access::DEVELOPER : Gitlab::Access::MASTER + access_level: Gitlab::CurrentSettings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE ? Gitlab::Access::DEVELOPER : Gitlab::Access::MASTER }] } @@ -1773,7 +1771,7 @@ class Project < ActiveRecord::Base end def use_hashed_storage - if self.new_record? && current_application_settings.hashed_storage_enabled + if self.new_record? && Gitlab::CurrentSettings.hashed_storage_enabled self.storage_version = LATEST_STORAGE_VERSION end end diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb index c72b01b64af..e42fd802b92 100644 --- a/app/models/project_services/kubernetes_service.rb +++ b/app/models/project_services/kubernetes_service.rb @@ -4,7 +4,6 @@ # After we've migrated data, we'll remove KubernetesService. This would happen in a few months. # If you're modyfiyng this class, please note that you should update the same change in Clusters::Platforms::Kubernetes. class KubernetesService < DeploymentService - include Gitlab::CurrentSettings include Gitlab::Kubernetes include ReactiveCaching @@ -231,7 +230,7 @@ class KubernetesService < DeploymentService { token: token, ca_pem: ca_pem, - max_session_time: current_application_settings.terminal_max_session_time + max_session_time: Gitlab::CurrentSettings.terminal_max_session_time } end diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index d28fed11ca8..609780c5587 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -2,8 +2,6 @@ class ProtectedBranch < ActiveRecord::Base include Gitlab::ShellAdapter include ProtectedRef - extend Gitlab::CurrentSettings - protected_ref_access_levels :merge, :push # Check if branch name is marked as protected in the system @@ -16,7 +14,7 @@ class ProtectedBranch < ActiveRecord::Base end def self.default_branch_protected? - current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_FULL || - current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE + Gitlab::CurrentSettings.default_branch_protection == Gitlab::Access::PROTECTION_FULL || + Gitlab::CurrentSettings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE end end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 05a16f11b59..7c8716f8c18 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -11,8 +11,6 @@ class Snippet < ActiveRecord::Base include Editable include Gitlab::SQL::Pattern - extend Gitlab::CurrentSettings - cache_markdown_field :title, pipeline: :single_line cache_markdown_field :description cache_markdown_field :content @@ -28,7 +26,7 @@ class Snippet < ActiveRecord::Base default_content_html_invalidator || file_name_changed? end - default_value_for(:visibility_level) { current_application_settings.default_snippet_visibility } + default_value_for(:visibility_level) { Gitlab::CurrentSettings.default_snippet_visibility } belongs_to :author, class_name: 'User' belongs_to :project diff --git a/app/models/user.rb b/app/models/user.rb index 89e787c3274..cad118f5502 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,10 +2,8 @@ require 'carrierwave/orm/activerecord' class User < ActiveRecord::Base extend Gitlab::ConfigHelper - extend Gitlab::CurrentSettings include Gitlab::ConfigHelper - include Gitlab::CurrentSettings include Gitlab::SQL::Pattern include AfterCommitQueue include Avatarable @@ -30,7 +28,7 @@ class User < ActiveRecord::Base add_authentication_token_field :rss_token default_value_for :admin, false - default_value_for(:external) { current_application_settings.user_default_external } + default_value_for(:external) { Gitlab::CurrentSettings.user_default_external } default_value_for :can_create_group, gitlab_config.default_can_create_group default_value_for :can_create_team, false default_value_for :hide_no_ssh_key, false @@ -660,11 +658,11 @@ class User < ActiveRecord::Base end def allow_password_authentication_for_web? - current_application_settings.password_authentication_enabled_for_web? && !ldap_user? + Gitlab::CurrentSettings.password_authentication_enabled_for_web? && !ldap_user? end def allow_password_authentication_for_git? - current_application_settings.password_authentication_enabled_for_git? && !ldap_user? + Gitlab::CurrentSettings.password_authentication_enabled_for_git? && !ldap_user? end def can_change_username? @@ -792,7 +790,7 @@ class User < ActiveRecord::Base # without this safeguard! return unless has_attribute?(:projects_limit) && projects_limit.nil? - self.projects_limit = current_application_settings.default_projects_limit + self.projects_limit = Gitlab::CurrentSettings.default_projects_limit end def requires_ldap_check? @@ -1215,7 +1213,7 @@ class User < ActiveRecord::Base else # Only revert these back to the default if they weren't specifically changed in this update. self.can_create_group = gitlab_config.default_can_create_group unless can_create_group_changed? - self.projects_limit = current_application_settings.default_projects_limit unless projects_limit_changed? + self.projects_limit = Gitlab::CurrentSettings.default_projects_limit unless projects_limit_changed? end end @@ -1223,15 +1221,15 @@ class User < ActiveRecord::Base valid = true error = nil - if current_application_settings.domain_blacklist_enabled? - blocked_domains = current_application_settings.domain_blacklist + if Gitlab::CurrentSettings.domain_blacklist_enabled? + blocked_domains = Gitlab::CurrentSettings.domain_blacklist if domain_matches?(blocked_domains, email) error = 'is not from an allowed domain.' valid = false end end - allowed_domains = current_application_settings.domain_whitelist + allowed_domains = Gitlab::CurrentSettings.domain_whitelist unless allowed_domains.blank? if domain_matches?(allowed_domains, email) valid = true |