feat: seat count in class
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
"start_date",
|
"start_date",
|
||||||
"end_date",
|
"end_date",
|
||||||
"column_break_4",
|
"column_break_4",
|
||||||
|
"seat_count",
|
||||||
"description",
|
"description",
|
||||||
"section_break_6",
|
"section_break_6",
|
||||||
"students",
|
"students",
|
||||||
@@ -71,11 +72,16 @@
|
|||||||
"fieldtype": "Code",
|
"fieldtype": "Code",
|
||||||
"label": "Custom Component",
|
"label": "Custom Component",
|
||||||
"options": "HTML"
|
"options": "HTML"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "seat_count",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Seat Count"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-03-02 22:47:13.139289",
|
"modified": "2023-05-03 20:57:22.579068",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Class",
|
"name": "LMS Class",
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import json
|
|||||||
|
|
||||||
class LMSClass(Document):
|
class LMSClass(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
if self.seat_count:
|
||||||
|
self.validate_seats_left()
|
||||||
self.validate_duplicate_students()
|
self.validate_duplicate_students()
|
||||||
self.validate_membership()
|
self.validate_membership()
|
||||||
|
|
||||||
@@ -36,6 +38,10 @@ class LMSClass(Document):
|
|||||||
if not frappe.db.exists(filters):
|
if not frappe.db.exists(filters):
|
||||||
frappe.get_doc(filters).save()
|
frappe.get_doc(filters).save()
|
||||||
|
|
||||||
|
def validate_seats_left(self):
|
||||||
|
if self.seat_count < len(self.students):
|
||||||
|
frappe.throw(_("There are no seats available in this class."))
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def add_student(email, class_name):
|
def add_student(email, class_name):
|
||||||
|
|||||||
Reference in New Issue
Block a user