feat: Refactored some enrollment functions
This commit is contained in:
parent
b72ba416ff
commit
531d2761cf
@ -100,6 +100,7 @@ class Student(Document):
|
||||
return progress
|
||||
|
||||
def enroll_in_program(self, program_name):
|
||||
try:
|
||||
enrollment = frappe.get_doc({
|
||||
"doctype": "Program Enrollment",
|
||||
"student": self.name,
|
||||
@ -108,11 +109,15 @@ class Student(Document):
|
||||
"enrollment_date": frappe.utils.datetime.datetime.now()
|
||||
})
|
||||
enrollment.save(ignore_permissions=True)
|
||||
except frappe.exceptions.ValidationError:
|
||||
enrollment_name = frappe.get_list("Program Enrollment", filters={"student": self.name, "Program": program_name})[0].name
|
||||
return frappe.get_doc("Program Enrollment", enrollment_name)
|
||||
else:
|
||||
enrollment.submit()
|
||||
frappe.db.commit()
|
||||
return enrollment
|
||||
|
||||
def enroll_in_course(self, course_name, program_enrollment, enrollment_date=frappe.utils.datetime.datetime.now()):
|
||||
try:
|
||||
enrollment = frappe.get_doc({
|
||||
"doctype": "Course Enrollment",
|
||||
"student": self.name,
|
||||
@ -121,7 +126,11 @@ class Student(Document):
|
||||
"enrollment_date": enrollment_date
|
||||
})
|
||||
enrollment.save(ignore_permissions=True)
|
||||
frappe.db.commit()
|
||||
except frappe.exceptions.ValidationError:
|
||||
enrollment_name = frappe.get_list("Program Enrollment", filters={"student": self.name, "course": course_name, "program_enrollment": program_enrollment})[0].name
|
||||
return frappe.get_doc("Program Enrollment", enrollment_name)
|
||||
else:
|
||||
return enrollment
|
||||
|
||||
def get_timeline_data(doctype, name):
|
||||
'''Return timeline for attendance'''
|
||||
|
Loading…
Reference in New Issue
Block a user