diff --git a/frontend/src/pages/Batches.vue b/frontend/src/pages/Batches.vue index c471bc48..b9821622 100644 --- a/frontend/src/pages/Batches.vue +++ b/frontend/src/pages/Batches.vue @@ -130,7 +130,6 @@ import { Breadcrumbs, Button, - call, createListResource, Dropdown, FormControl, @@ -185,24 +184,27 @@ const batches = createListResource({ cache: ['batches', user.data?.name], pageLength: pageLength.value, start: start.value, - onSuccess(data) { - let allCategories = data.map((batch) => batch.category) - allCategories = allCategories.filter( - (category, index) => allCategories.indexOf(category) === index && category - ) - if (categories.value.length <= allCategories.length) { - updateCategories(data) - } - }, }) +const setCategories = (data) => { + let allCategories = data.map((batch) => batch.category) + allCategories = allCategories.filter( + (category, index) => allCategories.indexOf(category) === index && category + ) + if (categories.value.length <= allCategories.length) { + updateCategories(data) + } +} + const updateBatches = () => { updateFilters() batches.update({ filters: filters.value, orderBy: orderBy.value, }) - batches.reload() + batches.reload().then((data) => { + setCategories(data) + }) } const updateFilters = () => { diff --git a/frontend/src/pages/Courses.vue b/frontend/src/pages/Courses.vue index 8c1f91ae..48fc9200 100644 --- a/frontend/src/pages/Courses.vue +++ b/frontend/src/pages/Courses.vue @@ -168,9 +168,6 @@ const courses = createListResource({ cache: ['courses', user.data?.name], pageLength: pageLength.value, start: start.value, - onSuccess(data) { - setCategories(data) - }, }) const setCategories = (data) => { @@ -219,7 +216,9 @@ const updateCourses = () => { courses.update({ filters: filters.value, }) - courses.reload() + courses.reload().then((data) => { + setCategories(data) + }) } const updateFilters = () => { diff --git a/lms/auth.py b/lms/auth.py index f4da21dd..e465c71d 100644 --- a/lms/auth.py +++ b/lms/auth.py @@ -32,7 +32,7 @@ ALLOWED_PATHS = [ "/api/method/frappe.onboarding.get_onboarding_status", "/api/method/frappe.utils.print_format.download_pdf", "/api/method/frappe.desk.search.search_link", - "/api/method/frappe.core.doctype.communication.email.make_email", + "/api/method/frappe.core.doctype.communication.email.make", ] @@ -53,7 +53,6 @@ def authenticate(): if path.startswith("/lms") or path.startswith("/api/method/lms."): return - print(ALLOWED_PATHS) if path in ALLOWED_PATHS: return frappe.throw(f"Access not allowed for this URL: {path}", frappe.PermissionError) diff --git a/lms/lms/doctype/course_evaluator/test_course_evaluator.py b/lms/lms/doctype/course_evaluator/test_course_evaluator.py index 605bb553..1dc2eb24 100644 --- a/lms/lms/doctype/course_evaluator/test_course_evaluator.py +++ b/lms/lms/doctype/course_evaluator/test_course_evaluator.py @@ -5,7 +5,7 @@ from frappe.tests import UnitTestCase from frappe.utils import add_days, format_time, getdate -from lms.lms.doctype.course_evaluator.course_evaluator import get_schedule +from lms.lms.doctype.course_evaluator.course_evaluator import get_schedule, get_schedule_range_end_date from lms.lms.test_utils import TestUtils @@ -51,17 +51,10 @@ class TestCourseEvaluator(UnitTestCase): first_date = add_days(today, offset_wednesday) return first_date - def calculated_last_date_of_schedule(self, first_date): - last_day = add_days(getdate(), 56) - offset_monday = (0 - last_day.weekday() + 7) % 7 # 0 for Monday - offset_wednesday = (2 - last_day.weekday() + 7) % 7 # 2 for Wednesday - - if offset_monday < offset_wednesday and offset_monday <= 4: - last_day = add_days(last_day, offset_monday) - elif offset_wednesday <= 4: - last_day = add_days(last_day, offset_wednesday) - else: - last_day = add_days(last_day, min(offset_monday, offset_wednesday) + 7) + def calculated_last_date_of_schedule(self): + last_day = getdate(get_schedule_range_end_date(getdate(), self.batch.name)) + while last_day.weekday() not in (0, 2): + last_day = add_days(last_day, -1) return last_day