From 31c8e71d8ec3e0070118a545254d592fc8ad4baa Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 5 Apr 2020 19:24:32 +0000 Subject: [PATCH] Set time entry author in controller (#32774). git-svn-id: http://svn.redmine.org/redmine/trunk@19677 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 1 + app/models/time_entry.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b442b355b..712f02f67 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -614,6 +614,7 @@ class IssuesController < ApplicationController time_entry = @time_entry || TimeEntry.new time_entry.project = @issue.project time_entry.issue = @issue + time_entry.author = User.current time_entry.user = User.current time_entry.spent_on = User.current.today time_entry.safe_attributes = params[:time_entry] diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 5f8e475d6..f8de391ee 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -50,6 +50,7 @@ class TimeEntry < ActiveRecord::Base validates_length_of :comments, :maximum => 1024, :allow_nil => true validates :spent_on, :date => true before_validation :set_project_if_nil + #TODO: remove this, author should be always explicitly set before_validation :set_author_if_nil validate :validate_time_entry