提交 1144b70a 编写于 作者: T Tomasz Maczukin

Change update_forks_visibility_level into after_update hook in Project model

上级 945e4293
......@@ -61,6 +61,19 @@ class Project < ActiveRecord::Base
update_column(:last_activity_at, self.created_at)
end
# update visibility_levet of forks
after_update :update_forks_visibility_level
def update_forks_visibility_level
return unless visibility_level < visibility_level_was
forks.each do |forked_project|
if forked_project.visibility_level > visibility_level
forked_project.visibility_level = visibility_level
forked_project.save!
end
end
end
ActsAsTaggableOn.strict_case_match = true
acts_as_taggable_on :tags
......
......@@ -13,7 +13,6 @@ module Projects
end
return false unless visibility_level_allowed?(new_visibility)
update_forks_visibility_level(new_visibility.to_i)
end
new_branch = params[:default_branch]
......@@ -42,18 +41,5 @@ module Projects
false
end
def update_forks_visibility_level(new_level)
return unless new_level < project.visibility_level
project.forks.each do |forked_project|
fork_level = forked_project.visibility_level
if fork_level > new_level
forked_project.visibility_level = new_level
forked_project.save!
end
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册