Skip to content

Commit

Permalink
Fix:timetable validation
Browse files Browse the repository at this point in the history
  • Loading branch information
saadindictrans committed Oct 27, 2023
1 parent a9b05f4 commit 8c0c09a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lms/lms/doctype/lms_batch/lms_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
cint,
format_date,
format_datetime,
get_time,
)
from lms.lms.utils import get_lessons, get_lesson_index, get_lesson_url
from lms.www.utils import get_quiz_details, get_assignment_details
Expand Down Expand Up @@ -116,23 +117,27 @@ def validate_seats_left(self):
def validate_timetable(self):
for schedule in self.timetable:
if schedule.start_time and schedule.end_time:
if (
schedule.start_time > schedule.end_time or schedule.start_time == schedule.end_time
):
if get_time(schedule.start_time) > get_time(schedule.end_time) or get_time(
schedule.start_time
) == get_time(schedule.end_time):
frappe.throw(
_("Row #{0} Start time cannot be greater than or equal to end time.").format(
schedule.idx
)
)

if schedule.start_time < self.start_time or schedule.start_time > self.end_time:
if get_time(schedule.start_time) < get_time(self.start_time) or get_time(
schedule.start_time
) > get_time(self.end_time):
frappe.throw(
_("Row #{0} Start time cannot be outside the batch duration.").format(
schedule.idx
)
)

if schedule.end_time < self.start_time or schedule.end_time > self.end_time:
if get_time(schedule.end_time) < get_time(self.start_time) or get_time(
schedule.end_time
) > get_time(self.end_time):
frappe.throw(
_("Row #{0} End time cannot be outside the batch duration.").format(schedule.idx)
)
Expand Down

0 comments on commit 8c0c09a

Please sign in to comment.