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