summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-10 12:05:54 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-10 12:05:54 +0000
commitbda04bc687e5fafc05d07fa234c96e49d9c4f3fc (patch)
tree9aefc4c84361cb769fc499d4e33c501d0f44a462 /app/helpers
parent7574ec4b85e03f1c1f5d957eee2ef7b29f718c80 (diff)
parent111ebe54712aca16f3ad0f3d859c1c036ccb9f09 (diff)
downloadgitlab-ce-bda04bc687e5fafc05d07fa234c96e49d9c4f3fc.tar.gz
Merge branch 'fork_visibility_level' into 'master'
Forks should not have more permissive visibility levels than the original https://dev.gitlab.org/gitlab/gitlabhq/issues/2286 See merge request !936
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/projects_helper.rb10
-rw-r--r--app/helpers/visibility_level_helper.rb6
2 files changed, 16 insertions, 0 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index cef23a52e34..aa15398cbed 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -92,6 +92,16 @@ module ProjectsHelper
end
end
+ def can_change_visibility_level?(project, current_user)
+ return false unless can?(current_user, :change_visibility_level, project)
+
+ if project.forked?
+ project.forked_from_project.visibility_level > Gitlab::VisibilityLevel::PRIVATE
+ else
+ true
+ end
+ end
+
private
def get_project_nav_tabs(project, current_user)
diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb
index 00d4c7f1051..b52cd23aba2 100644
--- a/app/helpers/visibility_level_helper.rb
+++ b/app/helpers/visibility_level_helper.rb
@@ -86,4 +86,10 @@ module VisibilityLevelHelper
def default_snippet_visibility
current_application_settings.default_snippet_visibility
end
+
+ def skip_level?(form_model, level)
+ form_model.is_a?(Project) &&
+ form_model.forked? &&
+ !Gitlab::VisibilityLevel.allowed_fork_levels(form_model.forked_from_project.visibility_level).include?(level)
+ end
end