fix: batch listing for current day batches
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" href="/favicon.png" />
|
<link rel="icon" href="{{ favicon or '/assets/lms/frontend/favicon.png' }}" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Frappe Learning</title>
|
<title>Frappe Learning</title>
|
||||||
<meta name="title" content="{{ meta.title }}" />
|
<meta name="title" content="{{ meta.title }}" />
|
||||||
|
|||||||
@@ -38,10 +38,10 @@
|
|||||||
v-model="title"
|
v-model="title"
|
||||||
:placeholder="__('Search by Title')"
|
:placeholder="__('Search by Title')"
|
||||||
type="text"
|
type="text"
|
||||||
class="min-w-40 lg:min-w-0 lg:w-32"
|
class="min-w-40 lg:min-w-0 lg:w-32 xl:w-40"
|
||||||
@input="updateBatches()"
|
@input="updateBatches()"
|
||||||
/>
|
/>
|
||||||
<div class="min-w-40 lg:min-w-0 lg:w-32">
|
<div class="min-w-40 lg:min-w-0 lg:w-32 xl:w-40">
|
||||||
<Select
|
<Select
|
||||||
v-if="categories.length"
|
v-if="categories.length"
|
||||||
v-model="currentCategory"
|
v-model="currentCategory"
|
||||||
@@ -101,6 +101,7 @@ import {
|
|||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { computed, inject, onMounted, ref, watch } from 'vue'
|
import { computed, inject, onMounted, ref, watch } from 'vue'
|
||||||
import { BookOpen, Plus } from 'lucide-vue-next'
|
import { BookOpen, Plus } from 'lucide-vue-next'
|
||||||
|
import { updateDocumentTitle } from '@/utils'
|
||||||
import BatchCard from '@/components/BatchCard.vue'
|
import BatchCard from '@/components/BatchCard.vue'
|
||||||
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
@@ -200,7 +201,7 @@ const updateTabFilter = () => {
|
|||||||
filters.value['published'] = 1
|
filters.value['published'] = 1
|
||||||
orderBy.value = 'start_date'
|
orderBy.value = 'start_date'
|
||||||
} else if (currentTab.value == 'Archived') {
|
} else if (currentTab.value == 'Archived') {
|
||||||
filters.value['start_date'] = ['<', dayjs().format('YYYY-MM-DD')]
|
filters.value['start_date'] = ['<=', dayjs().format('YYYY-MM-DD')]
|
||||||
} else if (currentTab.value == 'Unpublished') {
|
} else if (currentTab.value == 'Unpublished') {
|
||||||
filters.value['published'] = 0
|
filters.value['published'] = 0
|
||||||
}
|
}
|
||||||
@@ -283,4 +284,13 @@ const breadcrumbs = computed(() => [
|
|||||||
route: { name: 'Batches' },
|
route: { name: 'Batches' },
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const pageMeta = computed(() => {
|
||||||
|
return {
|
||||||
|
title: 'Batches',
|
||||||
|
description: 'All upcoming batches.',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
updateDocumentTitle(pageMeta)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -35,8 +35,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Course",
|
"label": "Course",
|
||||||
"options": "LMS Course",
|
"options": "LMS Course"
|
||||||
"reqd": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "expiry_date",
|
"fieldname": "expiry_date",
|
||||||
@@ -114,7 +113,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-09-11 11:37:20.419956",
|
"modified": "2025-01-16 11:42:51.449506",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Certificate",
|
"name": "LMS Certificate",
|
||||||
|
|||||||
@@ -1889,6 +1889,28 @@ def get_batches(filters=None, start=0, page_length=20, order_by="start_date"):
|
|||||||
page_length=page_length,
|
page_length=page_length,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(batches)
|
||||||
|
batchType = get_batch_type(filters)
|
||||||
|
if batchType == "upcoming":
|
||||||
|
batches_to_remove = list(
|
||||||
|
filter(
|
||||||
|
lambda batch: getdate(batch.start_date) == getdate()
|
||||||
|
and get_time_str(batch.start_time) < nowtime(),
|
||||||
|
batches,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
print(batches_to_remove)
|
||||||
|
batches = [batch for batch in batches if batch not in batches_to_remove]
|
||||||
|
elif batchType == "archived":
|
||||||
|
batches_to_remove = list(
|
||||||
|
filter(
|
||||||
|
lambda batch: getdate(batch.start_date) == getdate()
|
||||||
|
and get_time_str(batch.start_time) >= nowtime(),
|
||||||
|
batches,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
batches = [batch for batch in batches if batch not in batches_to_remove]
|
||||||
|
|
||||||
for batch in batches:
|
for batch in batches:
|
||||||
batch.instructors = get_instructors(batch.name)
|
batch.instructors = get_instructors(batch.name)
|
||||||
students_count = frappe.db.count("Batch Student", {"parent": batch.name})
|
students_count = frappe.db.count("Batch Student", {"parent": batch.name})
|
||||||
@@ -1903,3 +1925,16 @@ def get_batches(filters=None, start=0, page_length=20, order_by="start_date"):
|
|||||||
batch.price = fmt_money(batch.amount, 0, batch.currency)
|
batch.price = fmt_money(batch.amount, 0, batch.currency)
|
||||||
|
|
||||||
return batches
|
return batches
|
||||||
|
|
||||||
|
|
||||||
|
def get_batch_type(filters):
|
||||||
|
start_date_filter = filters.get("start_date")
|
||||||
|
batchType = None
|
||||||
|
if start_date_filter:
|
||||||
|
sign = start_date_filter[0]
|
||||||
|
if ">" in sign:
|
||||||
|
batchType = "upcoming"
|
||||||
|
elif "<" in sign:
|
||||||
|
batchType = "archived"
|
||||||
|
|
||||||
|
return batchType
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ def get_context():
|
|||||||
frappe.db.commit() # nosemgrep
|
frappe.db.commit() # nosemgrep
|
||||||
context.csrf_token = csrf_token
|
context.csrf_token = csrf_token
|
||||||
capture("active_site", "lms")
|
capture("active_site", "lms")
|
||||||
|
context.favicon = frappe.db.get_single_value("Website Settings", "favicon")
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user