diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-09-01 16:49:09 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-09-06 12:07:20 -0700 |
commit | 1cc7f4a45d9e9fdf1943eb92d3cd2071ba497337 (patch) | |
tree | cdaebcf4f86d442a00a45d7a6bab4584a7b48dbd /app | |
parent | 8437a24ff46220e2813ce3d82a52062dd259276b (diff) | |
download | gitlab-ce-1cc7f4a45d9e9fdf1943eb92d3cd2071ba497337.tar.gz |
Enable share_with_group_lock on subgroup
…when needed
Diffstat (limited to 'app')
-rw-r--r-- | app/models/namespace.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb index e7cbc5170e8..aeda829415a 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -44,6 +44,10 @@ class Namespace < ActiveRecord::Base 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_update :sync_share_with_group_lock_with_parent, if: :parent_changed? + after_commit :force_share_with_group_lock_on_descendants, on: :update, if: -> { previous_changes.key?('share_with_group_lock') && share_with_group_lock? } + # Legacy Storage specific hooks after_update :move_dir, if: :path_changed? @@ -219,4 +223,14 @@ class Namespace < ActiveRecord::Base errors.add(:parent_id, "has too deep level of nesting") end end + + def sync_share_with_group_lock_with_parent + if has_parent? && parent.share_with_group_lock? + self.share_with_group_lock = true + end + end + + def force_share_with_group_lock_on_descendants + descendants.update_all(share_with_group_lock: true) + end end |