Project

General

Profile

Feature #3848 » patch-3848_log-time-for-others-users-ld.diff

Lars Dornheim, 2011-08-05 05:57

View differences:

redmine-1.1/app/controllers/timelog_controller.rb 2011-08-05 05:30:17.000000000 +0200
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
def create
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
# Check if current user has permissions to edit time entries
if request.post? and User.current.allowed_to?(:edit_time_entries, @project)
user = User.find(params[:time_entry][:user_id])
else
user = User.current
end
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => user, :spent_on => User.current.today)
@time_entry.attributes = params[:time_entry]
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
redmine-1.1/app/helpers/timelog_helper.rb 2011-08-05 01:49:47.000000000 +0200
collection
end
# Returns a collection of users for a select field.
def user_collection_for_select_options
users = @projects = User.find(:all)
collection = []
users.each do |a|
roles = a.roles_for_project(@project)
collection << [a.name, a.id] if roles and roles.detect {|role| role.member? && role.allowed_to?(:log_time)}
end
collection
end
def select_hours(data, criteria, value)
if value.to_s.empty?
data.select {|row| row[criteria].blank? }
redmine-1.1/app/models/time_entry.rb 2011-08-05 05:46:02.000000000 +0200
belongs_to :user
belongs_to :activity, :class_name => 'TimeEntryActivity', :foreign_key => 'activity_id'
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
attr_protected :project_id, :tyear, :tmonth, :tweek
acts_as_customizable
acts_as_event :title => Proc.new {|o| "#{l_hours(o.hours)} (#{(o.issue || o.project).event_title})"},
redmine-1.1/app/views/timelog/edit.rhtml 2011-08-05 01:49:47.000000000 +0200
<div class="box">
<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>
<% if User.current.allowed_to?(:edit_time_entries, @project) %>
<p> <%= f.select :user_id, user_collection_for_select_options, :required => true %></p>
<% end %>
<p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
<p><%= f.text_field :hours, :size => 6, :required => true %></p>
<p><%= f.text_field :comments, :size => 100 %></p>
(10-10/21)