feat: seat count in class

This commit is contained in:
Jannat Patel
2023-05-03 21:02:57 +05:30
parent 4f52a73029
commit e10feb3c36
2 changed files with 13 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
"start_date",
"end_date",
"column_break_4",
"seat_count",
"description",
"section_break_6",
"students",
@@ -71,11 +72,16 @@
"fieldtype": "Code",
"label": "Custom Component",
"options": "HTML"
},
{
"fieldname": "seat_count",
"fieldtype": "Int",
"label": "Seat Count"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-03-02 22:47:13.139289",
"modified": "2023-05-03 20:57:22.579068",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Class",

View File

@@ -12,6 +12,8 @@ import json
class LMSClass(Document):
def validate(self):
if self.seat_count:
self.validate_seats_left()
self.validate_duplicate_students()
self.validate_membership()
@@ -36,6 +38,10 @@ class LMSClass(Document):
if not frappe.db.exists(filters):
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()
def add_student(email, class_name):