From b87d53d9b49e06a6bf8cbaff0cc7eb865f15f910 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sun, 27 Oct 2019 10:40:52 +0200 Subject: [PATCH 1/2] Add permission to import time entries --- app/models/time_entry_import.rb | 2 +- app/views/timelog/index.html.erb | 2 +- lib/redmine.rb | 1 + test/fixtures/roles.yml | 24 ++++++++++++------------ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/models/time_entry_import.rb b/app/models/time_entry_import.rb index 125eee093..66b762f74 100644 --- a/app/models/time_entry_import.rb +++ b/app/models/time_entry_import.rb @@ -23,7 +23,7 @@ class TimeEntryImport < Import end def self.authorized?(user) - user.allowed_to?(:log_time, nil, :global => true) + user.allowed_to?(:import_time_entries, nil, :global => true) end # Returns the objects that were imported diff --git a/app/views/timelog/index.html.erb b/app/views/timelog/index.html.erb index 2de121806..e33855cd8 100644 --- a/app/views/timelog/index.html.erb +++ b/app/views/timelog/index.html.erb @@ -6,7 +6,7 @@ {:controller => 'projects', :action => 'settings', :id => @project, :tab => 'activities'}, :class => 'icon icon-settings' if User.current.allowed_to?(:manage_project_activities, @project) %> <%= actions_dropdown do %> - <% if User.current.allowed_to?(:log_time, @project, :global => true) %> + <% if User.current.allowed_to?(:import_time_entries, @project, :global => true) %> <%= link_to l(:button_import), new_time_entries_import_path %> <% end %> <% end %> diff --git a/lib/redmine.rb b/lib/redmine.rb index f1d5c85c5..31a62c0a8 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -132,6 +132,7 @@ Redmine::AccessControl.map do |map| map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin map.permission :manage_project_activities, {:projects => :settings, :project_enumerations => [:update, :destroy]}, :require => :member map.permission :log_time_for_other_users, :require => :member + map.permission :import_time_entries, {} end map.project_module :news do |map| diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml index 072440d31..13433874e 100644 --- a/test/fixtures/roles.yml +++ b/test/fixtures/roles.yml @@ -1,12 +1,12 @@ ---- -roles_001: +--- +roles_001: name: Manager id: 1 builtin: 0 issues_visibility: all users_visibility: all permissions: | - --- + --- - :add_project - :edit_project - :close_project @@ -36,6 +36,7 @@ roles_001: - :view_time_entries - :edit_time_entries - :delete_time_entries + - :import_time_entries - :view_news - :manage_news - :comment_news @@ -67,14 +68,14 @@ roles_001: - :import_issues position: 1 -roles_002: +roles_002: name: Developer id: 2 builtin: 0 issues_visibility: default users_visibility: all permissions: | - --- + --- - :edit_project - :manage_members - :manage_versions @@ -117,14 +118,14 @@ roles_002: - :view_changesets position: 2 -roles_003: +roles_003: name: Reporter id: 3 builtin: 0 issues_visibility: default users_visibility: all permissions: | - --- + --- - :edit_project - :manage_members - :manage_versions @@ -160,14 +161,14 @@ roles_003: - :view_changesets position: 3 -roles_004: +roles_004: name: Non member id: 4 builtin: 1 issues_visibility: default users_visibility: all permissions: | - --- + --- - :view_issues - :add_issues - :edit_issues @@ -192,14 +193,14 @@ roles_004: - :view_changesets position: 1 -roles_005: +roles_005: name: Anonymous id: 5 builtin: 2 issues_visibility: default users_visibility: all permissions: | - --- + --- - :view_issues - :add_issue_notes - :view_gantt @@ -215,4 +216,3 @@ roles_005: - :view_changesets position: 1 - -- 2.22.0