brotherton-erpnext/erpnext/education/__init__.py
Rushabh Mehta a2288ff8e7 fix(assessment_result): student must be in group (#15255)
* fix(assessment_result): student must be in group

* fix(test_student_group): raise correct exception

* fix(unused-import): assessment-plan.py

* fix(tests)

* fix(tests)

* fix(test)

* fix(tests)
2018-08-31 16:12:49 +05:30

11 lines
458 B
Python

import frappe
from frappe import _
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)