Aditya Hase | f3c22f3 | 2019-01-22 18:22:20 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 2 | |
Rushabh Mehta | a2288ff | 2018-08-31 16:12:49 +0530 | [diff] [blame] | 3 | import frappe |
| 4 | from frappe import _ |
| 5 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 6 | |
Rushabh Mehta | a2288ff | 2018-08-31 16:12:49 +0530 | [diff] [blame] | 7 | class StudentNotInGroupError(frappe.ValidationError): pass |
| 8 | |
| 9 | def 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) |