Project

General

Profile

Feature #3848 » time-spent-by-another-user-v.0.2.patch

Oleg Volkov, 2010-03-18 12:04

View differences:

redmine/app/controllers/timelog_controller.rb 2010-03-18 13:39:08.467131702 +0300
210 210
  
211 211
  def edit
212 212
    (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
213
    @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
214
    @time_entry.attributes = params[:time_entry]
213
    if request.post? and User.current.allowed_to?(:edit_time_entries, @project)
214
      user = User.find(Hash[params[:time_entry].to_a]["user_id"].to_i)
215
    else
216
      user = User.current
217
    end
218
    @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => user, :spent_on => User.current.today)
219
    @time_entry.send(:attributes=, params[:time_entry], false)
215 220
    
216 221
    call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
217 222
    
redmine/app/helpers/timelog_helper.rb 2010-03-18 14:01:34.015608836 +0300
52 52
    activities.each { |a| collection << [a.name, a.id] }
53 53
    collection
54 54
  end
55

  
56
  def user_collection_for_select_options
57
    users = @projects = User.find(:all)
58
    collection = []
59
    users.each do |a|
60
      roles = a.roles_for_project(@project)
61
      collection << [a.name, a.id] if roles and roles.detect {|role| role.member? && role.allowed_to?(:log_time)}
62
    end
63
    collection
64
  end
55 65
  
56 66
  def select_hours(data, criteria, value)
57 67
  	if value.to_s.empty?
redmine/app/views/timelog/edit.rhtml 2010-03-14 11:01:31.816092433 +0300
6 6

  
7 7
<div class="box">
8 8
<p><%= f.text_field :issue_id, :size => 6 %> <em><%= h("#{@time_entry.issue.tracker.name} ##{@time_entry.issue.id}: #{@time_entry.issue.subject}") if @time_entry.issue %></em></p>
9
<% if User.current.allowed_to?(:edit_time_entries, @project) %>
10
  <p> <%= f.select :user_id, user_collection_for_select_options, :required => true %> </p>
11
<% end %>
9 12
<p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
10 13
<p><%= f.text_field :hours, :size => 6, :required => true %></p>
11 14
<p><%= f.text_field :comments, :size => 100 %></p>
(8-8/21)