feat: Refactored some enrollment functions
This commit is contained in:
parent
b72ba416ff
commit
531d2761cf
@ -100,28 +100,37 @@ class Student(Document):
|
|||||||
return progress
|
return progress
|
||||||
|
|
||||||
def enroll_in_program(self, program_name):
|
def enroll_in_program(self, program_name):
|
||||||
enrollment = frappe.get_doc({
|
try:
|
||||||
"doctype": "Program Enrollment",
|
enrollment = frappe.get_doc({
|
||||||
"student": self.name,
|
"doctype": "Program Enrollment",
|
||||||
"academic_year": frappe.get_last_doc("Academic Year").name,
|
"student": self.name,
|
||||||
"program": program_name,
|
"academic_year": frappe.get_last_doc("Academic Year").name,
|
||||||
"enrollment_date": frappe.utils.datetime.datetime.now()
|
"program": program_name,
|
||||||
})
|
"enrollment_date": frappe.utils.datetime.datetime.now()
|
||||||
enrollment.save(ignore_permissions=True)
|
})
|
||||||
enrollment.submit()
|
enrollment.save(ignore_permissions=True)
|
||||||
frappe.db.commit()
|
except frappe.exceptions.ValidationError:
|
||||||
return enrollment
|
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()
|
||||||
|
return enrollment
|
||||||
|
|
||||||
def enroll_in_course(self, course_name, program_enrollment, enrollment_date=frappe.utils.datetime.datetime.now()):
|
def enroll_in_course(self, course_name, program_enrollment, enrollment_date=frappe.utils.datetime.datetime.now()):
|
||||||
enrollment = frappe.get_doc({
|
try:
|
||||||
"doctype": "Course Enrollment",
|
enrollment = frappe.get_doc({
|
||||||
"student": self.name,
|
"doctype": "Course Enrollment",
|
||||||
"course": course_name,
|
"student": self.name,
|
||||||
"program_enrollment": program_enrollment,
|
"course": course_name,
|
||||||
"enrollment_date": enrollment_date
|
"program_enrollment": program_enrollment,
|
||||||
})
|
"enrollment_date": enrollment_date
|
||||||
enrollment.save(ignore_permissions=True)
|
})
|
||||||
frappe.db.commit()
|
enrollment.save(ignore_permissions=True)
|
||||||
|
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):
|
def get_timeline_data(doctype, name):
|
||||||
'''Return timeline for attendance'''
|
'''Return timeline for attendance'''
|
||||||
|
Loading…
Reference in New Issue
Block a user