chore: refactor utils.get_current_student

This commit is contained in:
scmmishra
2019-04-22 12:03:17 +05:30
parent 823d89cf66
commit 327334a830
2 changed files with 13 additions and 23 deletions

View File

@@ -66,9 +66,9 @@ def get_current_student():
return None
try:
student_id = frappe.get_all("Student", {"student_email_id": email}, ["name"])[0].name
return student_id
except IndexError:
return None
return frappe.get_doc("Student", student_id)
except (IndexError, frappe.DoesNotExistError):
frappe.throw(_("Student with email {0} does not exist.".format(email)))
def check_super_access():
current_user = frappe.get_doc('User', frappe.session.user)