OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
add validations for time entries
Klaus Zanders4f4b8c8891d9
diff --git a/modules/costs/app/models/time_entry.rb b/modules/costs/app/models/time_entry.rbindex ad9d0c005b6..93b5b3ea544 100644--- a/modules/costs/app/models/time_entry.rb+++ b/modules/costs/app/models/time_entry.rb@@ -44,6 +44,23 @@ class TimeEntry < ApplicationRecordvalidates_presence_of :hours, if: -> { !ongoing? }validates_numericality_of :hours, allow_nil: true, message: :invalid+ validates :start_time, :end_time,+ presence: true,+ if: -> { TimeEntry.must_track_start_and_end_time? }++ validates :start_time,+ numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 60 * 24 },+ allow_blank: true++ validates :end_time,+ numericality: {+ only_integer: true,+ greater_than: ->(te) { te.start_time.to_i },+ less_than_or_equal_to: 60 * 24+ # TODO: nice error message+ },+ allow_blank: true+scope :on_work_packages, ->(work_packages) { where(work_package_id: work_packages) }extend ::TimeEntries::TimeEntryScopes