915b34391c
* chore: Added isort to pre-commit config * chore: Sort imports with isort * chore: Clean up imports with pycln * chore: Sort imports with isort * chore: Fix import issues * chore: Clean up sider issues * chore: Remove import errors from flake8 ignore list * chore: Clean up lint issues
14 lines
500 B
Python
14 lines
500 B
Python
from __future__ import unicode_literals
|
|
|
|
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)
|