Feature #13244 » 0001-Rework patch-from-13244.patch
| app/models/setting.rb | ||
|---|---|---|
|
twofa == '3'
|
||
|
end
|
||
|
def self.timelog_days_within_past
|
||
|
[Setting.timelog_accept_within_past_days.to_i, 0].max
|
||
|
end
|
||
|
# Helper that returns an array based on per_page_options setting
|
||
|
def self.per_page_options_array
|
||
|
per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort
|
||
| app/models/time_entry.rb | ||
|---|---|---|
|
errors.add :activity_id, :inclusion if activity_id_changed? && project && !project.activities.include?(activity)
|
||
|
if spent_on && spent_on_changed? && user
|
||
|
errors.add :base, I18n.t(:error_spent_on_future_date) if !Setting.timelog_accept_future_dates? && (spent_on > user.today)
|
||
|
max_past_date = user.today - Setting.timelog_days_within_past
|
||
|
errors.add :base, I18n.t(:error_spent_on_past_date, :max_days => Setting.timelog_accept_within_past_days.to_i, :max_past_date => format_date(max_past_date)) if spent_on < max_past_date
|
||
|
end
|
||
|
if !Setting.timelog_accept_closed_issues? && issue&.closed? && issue.was_closed?
|
||
|
errors.add :base, I18n.t(:error_spent_on_closed_issue)
|
||
| app/views/settings/_timelog.html.erb | ||
|---|---|---|
|
<p><%= setting_check_box :timelog_accept_future_dates %></p>
|
||
|
<p><%= setting_check_box :timelog_accept_closed_issues %></p>
|
||
|
<p><%= setting_text_field :timelog_accept_within_past_days, :size => 6 %> <%= l(:label_day_plural) %></p>
|
||
|
</div>
|
||
|
<fieldset class="box">
|
||
| config/locales/en.yml | ||
|---|---|---|
|
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"
|
||
|
error_spent_on_closed_issue: "Cannot log time on a closed issue"
|
||
|
error_spent_on_past_date: "Cannot log time on a date older than %{max_past_date} (%{max_days} days ago)"
|
||
|
error_not_allowed_to_log_time_for_other_users: "You are not allowed to log time for other users"
|
||
|
error_can_not_execute_macro_html: "Error executing the <strong>%{name}</strong> macro (%{error})"
|
||
|
error_macro_does_not_accept_block: "This macro does not accept a block of text"
|
||
| ... | ... | |
|
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
|
||
|
setting_timelog_accept_closed_issues: Accept time logs on closed issues
|
||
|
setting_timelog_accept_within_past_days: Accept time logs within the past
|
||
|
setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject
|
||
|
setting_project_list_defaults: Projects list defaults
|
||
|
setting_twofa: Two-factor authentication
|
||
| config/settings.yml | ||
|---|---|---|
|
default: 1
|
||
|
timelog_accept_closed_issues:
|
||
|
default: 1
|
||
|
timelog_accept_within_past_days:
|
||
|
format: int
|
||
|
default: 36525
|
||
|
show_status_changes_in_mail_subject:
|
||
|
default: 1
|
||
|
wiki_tablesort_enabled:
|
||
| test/unit/time_entry_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_should_restrict_past_dates
|
||
|
with_settings :timelog_accept_within_past_days => '2' do
|
||
|
entry_two_days_ago = TimeEntry.generate
|
||
|
entry_two_days_ago.spent_on = User.current.today - 2
|
||
|
assert entry_two_days_ago.save
|
||
|
entry_three_days_ago = TimeEntry.generate
|
||
|
entry_three_days_ago.spent_on = User.current.today - 3
|
||
|
assert !entry_three_days_ago.save
|
||
|
assert entry_three_days_ago.errors[:base].present?
|
||
|
end
|
||
|
end
|
||
|
def test_should_require_spent_on
|
||
|
with_settings :timelog_accept_future_dates => '0' do
|
||
|
entry = TimeEntry.find(1)
|
||
- « Previous
- 1
- …
- 9
- 10
- 11
- Next »