2019-01-22 12:52:20 +00:00
|
|
|
from __future__ import unicode_literals
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2018-08-31 10:42:49 +00:00
|
|
|
import frappe
|
|
|
|
from frappe import _
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2018-08-31 10:42:49 +00:00
|
|
|
class StudentNotInGroupError(frappe.ValidationError): pass
|
|
|
|
|
|
|
|
def validate_student_belongs_to_group(student, student_group):
|
|
|
|
groups = frappe.db.get_all('Student Group Student', ['parent'], dict(student = student, active=1))
|
|
|
|
if not student_group in [d.parent for d in groups]:
|
|
|
|
frappe.throw(_('Student {0} does not belong to group {1}').format(frappe.bold(student), frappe.bold(student_group)),
|
|
|
|
StudentNotInGroupError)
|