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