don't allow course section end date to be before start date
test plan: * shouldn't be able to edit a course section to make the end date before the start date closes #CNVS-34979 Change-Id: I5712fce42de1084ba19f4e71043f7ef61d4dd4ba Reviewed-on: https://gerrit.instructure.com/103595 Tested-by: Jenkins QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
6bab8f544d
commit
a99d1aa1fd
|
@ -39,6 +39,7 @@ class CourseSection < ActiveRecord::Base
|
|||
validates_presence_of :course_id, :root_account_id, :workflow_state
|
||||
validates_length_of :sis_source_id, :maximum => maximum_string_length, :allow_nil => true, :allow_blank => false
|
||||
validates_length_of :name, :maximum => maximum_string_length, :allow_nil => false, :allow_blank => false
|
||||
validate :validate_section_dates
|
||||
|
||||
has_many :sis_post_grades_statuses
|
||||
|
||||
|
@ -50,6 +51,15 @@ class CourseSection < ActiveRecord::Base
|
|||
include StickySisFields
|
||||
are_sis_sticky :course_id, :name, :start_at, :end_at, :restrict_enrollments_to_section_dates
|
||||
|
||||
def validate_section_dates
|
||||
if start_at.present? && end_at.present? && end_at < start_at
|
||||
self.errors.add(:end_at, t("End date cannot be before start date"))
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def maybe_touch_all_enrollments
|
||||
self.touch_all_enrollments if self.start_at_changed? || self.end_at_changed? || self.restrict_enrollments_to_section_dates_changed? || self.course_id_changed?
|
||||
end
|
||||
|
|
|
@ -48,7 +48,6 @@ define([
|
|||
error: function(data) {
|
||||
$edit_section_form.loadingImage('remove');
|
||||
$edit_section_form.show();
|
||||
$edit_section_form.formErrors(data);
|
||||
}
|
||||
})
|
||||
.find(":text")
|
||||
|
|
Loading…
Reference in New Issue