mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Setting to restrict spent times on future dates (#3322).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@17719 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
27b6e595f7
commit
9f6277e07c
@ -136,6 +136,9 @@ class TimeEntry < ActiveRecord::Base
|
||||
errors.add :project_id, :invalid if project.nil?
|
||||
errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project) || @invalid_issue_id
|
||||
errors.add :activity_id, :inclusion if activity_id_changed? && project && !project.activities.include?(activity)
|
||||
if spent_on_changed? && user
|
||||
errors.add :base, I18n.t(:error_spent_on_future_date) if (!Setting.timelog_accept_future_dates? && (spent_on > user.today))
|
||||
end
|
||||
end
|
||||
|
||||
def hours=(h)
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
<p><%= setting_text_field :timelog_max_hours_per_day, :size => 6 %></p>
|
||||
|
||||
<p><%= setting_check_box :timelog_accept_0_hours %></p>
|
||||
|
||||
<p><%= setting_check_box :timelog_accept_future_dates %></p>
|
||||
</div>
|
||||
|
||||
<fieldset class="box">
|
||||
|
||||
@ -223,6 +223,7 @@ en:
|
||||
warning_fields_cleared_on_bulk_edit: "Changes will result in the automatic deletion of values from one or more fields on the selected objects"
|
||||
error_exceeds_maximum_hours_per_day: "Cannot log more than %{max_hours} hours on the same day (%{logged_hours} hours have already been logged)"
|
||||
error_can_not_delete_auth_source: "This authentication mode is in use and cannot be deleted."
|
||||
error_spent_on_future_date: "Cannot log time on a future date"
|
||||
|
||||
mail_subject_lost_password: "Your %{value} password"
|
||||
mail_body_lost_password: 'To change your password, click on the following link:'
|
||||
@ -469,6 +470,7 @@ en:
|
||||
setting_time_entry_list_defaults: Timelog list defaults
|
||||
setting_timelog_accept_0_hours: Accept time logs with 0 hours
|
||||
setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user
|
||||
setting_timelog_accept_future_dates: Accept time logs on future dates
|
||||
|
||||
permission_add_project: Create project
|
||||
permission_add_subprojects: Create subprojects
|
||||
|
||||
@ -308,3 +308,5 @@ timelog_accept_0_hours:
|
||||
timelog_max_hours_per_day:
|
||||
format: int
|
||||
default: 999
|
||||
timelog_accept_future_dates:
|
||||
default: 1
|
||||
|
||||
@ -119,6 +119,23 @@ class TimeEntryTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_accept_future_dates
|
||||
entry = TimeEntry.generate
|
||||
entry.spent_on = User.current.today + 1
|
||||
|
||||
assert entry.save
|
||||
end
|
||||
|
||||
def test_should_not_accept_future_dates_if_disabled
|
||||
with_settings :timelog_accept_future_dates => '0' do
|
||||
entry = TimeEntry.generate
|
||||
entry.spent_on = User.current.today + 1
|
||||
|
||||
assert !entry.save
|
||||
assert entry.errors[:base].present?
|
||||
end
|
||||
end
|
||||
|
||||
def test_spent_on_with_blank
|
||||
c = TimeEntry.new
|
||||
c.spent_on = ''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user