fix: upcoming batches based on start time

This commit is contained in:
Jannat Patel
2023-11-17 10:45:29 +05:30
parent a5a7184f9a
commit b70dfc8e82
4 changed files with 27 additions and 5 deletions

View File

@@ -120,12 +120,14 @@
{ {
"fieldname": "start_time", "fieldname": "start_time",
"fieldtype": "Time", "fieldtype": "Time",
"label": "Start Time" "label": "Start Time",
"reqd": 1
}, },
{ {
"fieldname": "end_time", "fieldname": "end_time",
"fieldtype": "Time", "fieldtype": "Time",
"label": "End Time" "label": "End Time",
"reqd": 1
}, },
{ {
"fieldname": "assessment_tab", "fieldname": "assessment_tab",
@@ -281,7 +283,7 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2023-10-12 12:53:37.351989", "modified": "2023-11-17 10:41:00.340418",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Batch", "name": "LMS Batch",

View File

@@ -308,12 +308,14 @@ const open_batch_dialog = () => {
label: __("Start Time"), label: __("Start Time"),
fieldname: "start_time", fieldname: "start_time",
default: batch_info && batch_info.start_time, default: batch_info && batch_info.start_time,
reqd: 1,
}, },
{ {
fieldtype: "Time", fieldtype: "Time",
label: __("End Time"), label: __("End Time"),
fieldname: "end_time", fieldname: "end_time",
default: batch_info && batch_info.end_time, default: batch_info && batch_info.end_time,
reqd: 1,
}, },
{ {
fieldtype: "Link", fieldtype: "Link",

View File

@@ -147,6 +147,18 @@
</span> </span>
</div> </div>
<div class="mt-auto mb-2">
<svg class="icon icon-sm">
<use href="#icon-clock"></use>
</svg>
<span>
{{ frappe.utils.format_time(batch.start_time, "HH:mm a") }} -
</span>
<span>
{{ frappe.utils.format_time(batch.end_time, "HH:mm a") }}
</span>
</div>
<div class="mb-2"> <div class="mb-2">
<svg class="icon icon-md"> <svg class="icon icon-md">
<use href="#icon-education"></use> <use href="#icon-education"></use>

View File

@@ -1,5 +1,5 @@
import frappe import frappe
from frappe.utils import getdate from frappe.utils import getdate, get_time_str, nowtime
from lms.lms.utils import ( from lms.lms.utils import (
has_course_moderator_role, has_course_moderator_role,
has_course_evaluator_role, has_course_evaluator_role,
@@ -19,6 +19,8 @@ def get_context(context):
"description", "description",
"start_date", "start_date",
"end_date", "end_date",
"start_time",
"end_time",
"paid_batch", "paid_batch",
"amount", "amount",
"currency", "currency",
@@ -43,7 +45,11 @@ def get_context(context):
) )
if not batch.published: if not batch.published:
private_batches.append(batch) private_batches.append(batch)
elif getdate(batch.start_date) <= getdate(): elif getdate(batch.start_date) < getdate():
past_batches.append(batch)
elif (
getdate(batch.start_date) == getdate() and get_time_str(batch.start_time) < nowtime()
):
past_batches.append(batch) past_batches.append(batch)
else: else:
upcoming_batches.append(batch) upcoming_batches.append(batch)