Project

General

Profile

Patch #32196 » 0001-Add-permission-to-import-time-entries.patch

Marius BĂLTEANU, 2019-10-28 09:06

View differences:

app/models/time_entry_import.rb
23 23
  end
24 24

  
25 25
  def self.authorized?(user)
26
    user.allowed_to?(:log_time, nil, :global => true)
26
    user.allowed_to?(:import_time_entries, nil, :global => true)
27 27
  end
28 28

  
29 29
  # Returns the objects that were imported
app/views/timelog/index.html.erb
6 6
            {:controller => 'projects', :action => 'settings', :id => @project, :tab => 'activities'},
7 7
            :class => 'icon icon-settings' if User.current.allowed_to?(:manage_project_activities, @project) %>
8 8
<%= actions_dropdown do %>
9
  <% if User.current.allowed_to?(:log_time, @project, :global => true) %>
9
  <% if User.current.allowed_to?(:import_time_entries, @project, :global => true) %>
10 10
    <%= link_to l(:button_import), new_time_entries_import_path %>
11 11
  <% end %>
12 12
<% end %>
lib/redmine.rb
132 132
    map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin
133 133
    map.permission :manage_project_activities, {:projects => :settings, :project_enumerations => [:update, :destroy]}, :require => :member
134 134
    map.permission :log_time_for_other_users, :require => :member
135
    map.permission :import_time_entries, {}
135 136
  end
136 137

  
137 138
  map.project_module :news do |map|
test/fixtures/roles.yml
1
--- 
2
roles_001: 
1
---
2
roles_001:
3 3
  name: Manager
4 4
  id: 1
5 5
  builtin: 0
6 6
  issues_visibility: all
7 7
  users_visibility: all
8 8
  permissions: |
9
    --- 
9
    ---
10 10
    - :add_project
11 11
    - :edit_project
12 12
    - :close_project
......
36 36
    - :view_time_entries
37 37
    - :edit_time_entries
38 38
    - :delete_time_entries
39
    - :import_time_entries
39 40
    - :view_news
40 41
    - :manage_news
41 42
    - :comment_news
......
67 68
    - :import_issues
68 69

  
69 70
  position: 1
70
roles_002: 
71
roles_002:
71 72
  name: Developer
72 73
  id: 2
73 74
  builtin: 0
74 75
  issues_visibility: default
75 76
  users_visibility: all
76 77
  permissions: |
77
    --- 
78
    ---
78 79
    - :edit_project
79 80
    - :manage_members
80 81
    - :manage_versions
......
117 118
    - :view_changesets
118 119

  
119 120
  position: 2
120
roles_003: 
121
roles_003:
121 122
  name: Reporter
122 123
  id: 3
123 124
  builtin: 0
124 125
  issues_visibility: default
125 126
  users_visibility: all
126 127
  permissions: |
127
    --- 
128
    ---
128 129
    - :edit_project
129 130
    - :manage_members
130 131
    - :manage_versions
......
160 161
    - :view_changesets
161 162

  
162 163
  position: 3
163
roles_004: 
164
roles_004:
164 165
  name: Non member
165 166
  id: 4
166 167
  builtin: 1
167 168
  issues_visibility: default
168 169
  users_visibility: all
169 170
  permissions: |
170
    --- 
171
    ---
171 172
    - :view_issues
172 173
    - :add_issues
173 174
    - :edit_issues
......
192 193
    - :view_changesets
193 194

  
194 195
  position: 1
195
roles_005: 
196
roles_005:
196 197
  name: Anonymous
197 198
  id: 5
198 199
  builtin: 2
199 200
  issues_visibility: default
200 201
  users_visibility: all
201 202
  permissions: |
202
    --- 
203
    ---
203 204
    - :view_issues
204 205
    - :add_issue_notes
205 206
    - :view_gantt
......
215 216
    - :view_changesets
216 217

  
217 218
  position: 1
218

  
(2-2/4)