From e585b77730b2a38173453bb5e437628fe6eb9844 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 6 Apr 2017 17:52:15 +0300 Subject: Change project view default for existing users and anonymous visitors to files+readme Signed-off-by: Dmitriy Zaporozhets --- app/controllers/projects_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 47f7e0b1b28..6807c37f972 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -345,7 +345,11 @@ class ProjectsController < Projects::ApplicationController end def project_view_files? - current_user && current_user.project_view == 'files' + if current_user + current_user.project_view == 'files' + else + project_view_files_allowed? + end end # Override extract_ref from ExtractsPath, which returns the branch and file path @@ -359,4 +363,8 @@ class ProjectsController < Projects::ApplicationController def get_id project.repository.root_ref end + + def project_view_files_allowed? + !project.empty_repo? && can?(current_user, :download_code, project) + end end -- cgit v1.2.1