Project

General

Profile

Defect #1507

Work Time cannot be saved with Redmine-trunk(r19944)

Added by Yuichi HARADA about 2 months ago. Updated 24 days ago.

Status:
新規(New)
Priority:
高め(High)
Assignee:
-
Target version:
-
Start date:
08/04/2020
Due date:
% Done:

0%

Estimated time:

Description

When the user assigned to the assignee of the issue attempts to enter and update the work time, an input error will occur.

Using:
  • Redmine: trunk (r19944)
  • Work Time: master branch ( git clone -b master https://github.com/tkusukawa/redmine_work_time.git )

Files

worktime-user-invalid.png (177 KB) worktime-user-invalid.png Yuichi HARADA, 08/04/2020 09:33 AM
1507-worktime-user-invalid.patch (2.53 KB) 1507-worktime-user-invalid.patch Yuichi HARADA, 08/04/2020 09:42 AM
#1

Updated by Yuichi HARADA about 2 months ago

The cause is that TimeEntry#author_id was added to the comparison condition by changing https://www.redmine.org/issues/32774 (https://www.redmine.org/projects/redmine/repository/revisions/19676/diff/trunk/app/models/time_entry.rb).

if user_id_changed? && user_id != author_id && !user.allowed_to?(:log_time_for_other_users, project)

I think the following patch will solve this issue.

diff --git a/app/controllers/work_time_controller.rb b/app/controllers/work_time_controller.rb
index 66018dd..97d27f9 100644
--- a/app/controllers/work_time_controller.rb
+++ b/app/controllers/work_time_controller.rb
@@ -781,7 +781,7 @@ private
               append_text += " add time entry of ##{issue.id.to_s}: #{tm_vals[:hours].to_f}h" 
               update_daily_memo(append_text, true)
             end
-            new_entry = TimeEntry.new(:project => issue.project, :issue => issue, :user => @this_user, :spent_on => @this_date)
+            new_entry = TimeEntry.new(:project => issue.project, :issue => issue, :user => @this_user, :author => User.current, :spent_on => @this_date)
             new_entry.safe_attributes = tm_vals
             new_entry.save
             append_error_message_html(@message, hour_update_check_error(new_entry, issue_id))
diff --git a/app/views/work_time/_user_day_table.html.erb b/app/views/work_time/_user_day_table.html.erb
index b3b86c5..2f07c66 100644
--- a/app/views/work_time/_user_day_table.html.erb
+++ b/app/views/work_time/_user_day_table.html.erb
@@ -147,7 +147,7 @@ prj_pack[:odr_issues].each do |issue_pack|
     <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][comments]", "", :size=>80)%>
   </td>
   <%if @custom_fields.length != 0
-      dummy_hour = TimeEntry.new(:project => issue.project, :issue => issue, :user => @this_user, :spent_on => @this_date)
+      dummy_hour = TimeEntry.new(:project => issue.project, :issue => issue, :user => @this_user, :author => User.current, :spent_on => @this_date)
       dummy_hour.custom_field_values.each do |cfv|
   %>
      <td><%= custom_field_tag "new_time_entry_"+issue_id.to_s+"_0", cfv %></td>
diff --git a/app/views/work_time/ajax_add_tickets_insert.html.erb b/app/views/work_time/ajax_add_tickets_insert.html.erb
index 6955beb..3f4b8e7 100644
--- a/app/views/work_time/ajax_add_tickets_insert.html.erb
+++ b/app/views/work_time/ajax_add_tickets_insert.html.erb
@@ -63,7 +63,7 @@
     <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][comments]", "", :size=>80)%>
   </td>
   <%if @custom_fields.length != 0
-      dummy_hour = TimeEntry.new(:project => @add_issue.project, :issue => @add_issue, :user => @this_user, :spent_on => @this_date)
+      dummy_hour = TimeEntry.new(:project => @add_issue.project, :issue => @add_issue, :user => @this_user, :author => User.current, :spent_on => @this_date)
       dummy_hour.custom_field_values.each do |cfv|
   %>
      <td><%= custom_field_tag "new_time_entry_"+@add_issue_id+"_"+@add_count, cfv %></td>
#2

Updated by Yuichi HARADA about 2 months ago

https://github.com/tkusukawa/redmine_work_time/pull/5
A pull request has already been created. please confirm.

#3

Updated by Yuichi HARADA 24 days ago

Tomohisa Kusukawa
I am very in trouble. Could you give priority to this issue and respond?

Also available in: Atom PDF