blob: cf8efde7df354e16a444535e20b4e1bb74bdee0d [file] [log] [blame]
Chillar Anand915b3432021-09-02 16:44:59 +05301
Rushabh Mehtaa2288ff2018-08-31 16:12:49 +05302import frappe
3from frappe import _
4
Chillar Anand915b3432021-09-02 16:44:59 +05305
Rushabh Mehtaa2288ff2018-08-31 16:12:49 +05306class StudentNotInGroupError(frappe.ValidationError): pass
7
8def validate_student_belongs_to_group(student, student_group):
9 groups = frappe.db.get_all('Student Group Student', ['parent'], dict(student = student, active=1))
10 if not student_group in [d.parent for d in groups]:
11 frappe.throw(_('Student {0} does not belong to group {1}').format(frappe.bold(student), frappe.bold(student_group)),
12 StudentNotInGroupError)