diff options
author | Annabel Dunstone Gray <annabel.dunstone@gmail.com> | 2017-04-11 16:47:50 +0300 |
---|---|---|
committer | Annabel Dunstone Gray <annabel.dunstone@gmail.com> | 2017-04-11 16:47:50 +0300 |
commit | a9ff23407c9df7da171b4ad07d40ff8a3f4fac24 (patch) | |
tree | 77159a69db78601ded0d78573ff932eb3c141c1b /app | |
parent | 248c06a05cd7abb347e35c70ff573843ab15f329 (diff) | |
parent | e585b77730b2a38173453bb5e437628fe6eb9844 (diff) |
Merge branch 'dz-fix-project-view' into 'master'
Change project view default for existing users and anonymous visitors to files+readme
Closes #29926
See merge request !10498
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects_controller.rb | 10 | ||||
-rw-r--r-- | app/helpers/preferences_helper.rb | 6 |
2 files changed, 14 insertions, 2 deletions
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 diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index 243ef39ef61..de959f13713 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -63,6 +63,10 @@ module PreferencesHelper end def anonymous_project_view - @project.empty_repo? || !can?(current_user, :download_code, @project) ? 'activity' : 'readme' + if !@project.empty_repo? && can?(current_user, :download_code, @project) + 'files' + else + 'activity' + end end end |