Skip to content

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

Add start_time validation

Mir Bhatiaa4fc8f2052b9
diff --git a/modules/meeting/app/contracts/recurring_meetings/update_contract.rb b/modules/meeting/app/contracts/recurring_meetings/update_contract.rb
index 358a4d9b5de..8b324bf8a59 100644
--- a/modules/meeting/app/contracts/recurring_meetings/update_contract.rb
+++ b/modules/meeting/app/contracts/recurring_meetings/update_contract.rb
@@ -28,12 +28,27 @@
module RecurringMeetings
class UpdateContract < BaseContract
+ include Redmine::I18n
+
validate :user_allowed_to_edit
+ validate :not_before_scheduled_time
def user_allowed_to_edit
unless user.allowed_in_project?(:edit_meetings, model.project)
errors.add :base, :error_unauthorized
end
end
+
+ def not_before_scheduled_time # rubocop:disable Metrics/AbcSize
+ return unless model.changed.intersect?(%w[start_time start_date])
+
+ if model.start_time < DateTime.now
+ if model.start_time.to_date < Time.zone.today
+ errors.add :start_date, :after, date: format_date(Date.yesterday)
+ else
+ errors.add :start_time_hour, :datetime_must_be_in_future
+ end
+ end
+ end
end
end