Rushabh Mehta | a2288ff | 2018-08-31 16:12:49 +0530 | [diff] [blame] | 1 | import frappe |
| 2 | from frappe import _ |
| 3 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 4 | |
Rushabh Mehta | a2288ff | 2018-08-31 16:12:49 +0530 | [diff] [blame] | 5 | class StudentNotInGroupError(frappe.ValidationError): pass |
| 6 | |
| 7 | def validate_student_belongs_to_group(student, student_group): |
| 8 | groups = frappe.db.get_all('Student Group Student', ['parent'], dict(student = student, active=1)) |
| 9 | if not student_group in [d.parent for d in groups]: |
| 10 | frappe.throw(_('Student {0} does not belong to group {1}').format(frappe.bold(student), frappe.bold(student_group)), |
| 11 | StudentNotInGroupError) |