fix: course and bath category filter issue

This commit is contained in:
Jannat Patel
2026-01-19 12:38:12 +05:30
parent c97a5e813c
commit 0883aedc1d
4 changed files with 22 additions and 29 deletions
+13 -11
View File
@@ -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 = () => {
+3 -4
View File
@@ -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 = () => {
+1 -2
View File
@@ -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)
@@ -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