Aditya Hase | f3c22f3 | 2019-01-22 18:22:20 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
Rushabh Mehta | a2288ff | 2018-08-31 16:12:49 +0530 | [diff] [blame] | 2 | import frappe |
| 3 | from frappe import _ |
| 4 | |
| 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) |