Commit 7541bc92 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'ee-unify-some-models' into 'master'

Move some EE only codes in models to their EE modules

See merge request gitlab-org/gitlab-ee!6276
parents e258cf31 9f72d4e6
class AuditEvent < ActiveRecord::Base class AuditEvent < ActiveRecord::Base
prepend EE::AuditEvent prepend EE::AuditEvent
include Gitlab::Utils::StrongMemoize
serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize
......
...@@ -7,7 +7,6 @@ class LfsObject < ActiveRecord::Base ...@@ -7,7 +7,6 @@ class LfsObject < ActiveRecord::Base
has_many :projects, through: :lfs_objects_projects has_many :projects, through: :lfs_objects_projects
scope :with_files_stored_locally, -> { where(file_store: [nil, LfsObjectUploader::Store::LOCAL]) } scope :with_files_stored_locally, -> { where(file_store: [nil, LfsObjectUploader::Store::LOCAL]) }
scope :with_files_stored_remotely, -> { where(file_store: LfsObjectUploader::Store::REMOTE) }
validates :oid, presence: true, uniqueness: true validates :oid, presence: true, uniqueness: true
......
...@@ -52,7 +52,6 @@ class Namespace < ActiveRecord::Base ...@@ -52,7 +52,6 @@ class Namespace < ActiveRecord::Base
after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?('share_with_group_lock') } 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_create :sync_share_with_group_lock_with_parent
before_create :sync_membership_lock_with_parent
before_update :sync_share_with_group_lock_with_parent, if: :parent_changed? before_update :sync_share_with_group_lock_with_parent, if: :parent_changed?
after_update :force_share_with_group_lock_on_descendants, if: -> { share_with_group_lock_changed? && share_with_group_lock? } after_update :force_share_with_group_lock_on_descendants, if: -> { share_with_group_lock_changed? && share_with_group_lock? }
...@@ -164,10 +163,6 @@ class Namespace < ActiveRecord::Base ...@@ -164,10 +163,6 @@ class Namespace < ActiveRecord::Base
Gitlab.config.lfs.enabled Gitlab.config.lfs.enabled
end end
def actual_size_limit
Gitlab::CurrentSettings.repository_size_limit
end
def shared_runners_enabled? def shared_runners_enabled?
projects.with_shared_runners.any? projects.with_shared_runners.any?
end end
...@@ -297,12 +292,6 @@ class Namespace < ActiveRecord::Base ...@@ -297,12 +292,6 @@ class Namespace < ActiveRecord::Base
end end
end end
def sync_membership_lock_with_parent
if parent&.membership_lock?
self.membership_lock = true
end
end
def force_share_with_group_lock_on_descendants def force_share_with_group_lock_on_descendants
return unless Group.supports_nested_groups? return unless Group.supports_nested_groups?
......
module EE module EE
module AuditEvent module AuditEvent
extend ActiveSupport::Concern extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
override :author_name
def author_name def author_name
details[:author_name].presence || user&.name details[:author_name].presence || user&.name
end end
......
...@@ -10,6 +10,7 @@ module EE ...@@ -10,6 +10,7 @@ module EE
after_destroy :log_geo_event after_destroy :log_geo_event
scope :geo_syncable, -> { with_files_stored_locally } scope :geo_syncable, -> { with_files_stored_locally }
scope :with_files_stored_remotely, -> { where(file_store: LfsObjectUploader::Store::REMOTE) }
end end
private private
......
...@@ -37,6 +37,8 @@ module EE ...@@ -37,6 +37,8 @@ module EE
validate :validate_plan_name validate :validate_plan_name
validate :validate_shared_runner_minutes_support validate :validate_shared_runner_minutes_support
before_create :sync_membership_lock_with_parent
end end
module ClassMethods module ClassMethods
...@@ -102,6 +104,16 @@ module EE ...@@ -102,6 +104,16 @@ module EE
actual_plan&.name || FREE_PLAN actual_plan&.name || FREE_PLAN
end end
def actual_size_limit
::Gitlab::CurrentSettings.repository_size_limit
end
def sync_membership_lock_with_parent
if parent&.membership_lock?
self.membership_lock = true
end
end
def shared_runner_minutes_supported? def shared_runner_minutes_supported?
if has_parent? if has_parent?
!Feature.enabled?(:shared_runner_minutes_on_root_namespace) !Feature.enabled?(:shared_runner_minutes_on_root_namespace)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment