Refactored student creation
This commit is contained in:
@@ -39,18 +39,6 @@ def enroll_student(source_name):
|
||||
program_enrollment.student_name = student.title
|
||||
program_enrollment.program = frappe.db.get_value("Student Applicant", source_name, "program")
|
||||
frappe.publish_realtime('enroll_student_progress', {"progress": [2, 4]}, user=frappe.session.user)
|
||||
student_user = frappe.get_doc({
|
||||
'doctype':'User',
|
||||
'first_name': student.first_name,
|
||||
'email': student.student_email_id,
|
||||
'send_welcome_email': 1,
|
||||
'user_type': 'Website User'
|
||||
})
|
||||
student_user.add_roles("Student", "LMS User")
|
||||
student_user.save()
|
||||
frappe.publish_realtime('enroll_student_progress', {"progress": [4, 4]}, user=frappe.session.user)
|
||||
update_password_link = student_user.reset_password()
|
||||
print(update_password_link)
|
||||
return program_enrollment
|
||||
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Web Academy Settings",
|
||||
"label": "LMS Settings",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@@ -414,7 +414,7 @@
|
||||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-10-30 17:33:56.143330",
|
||||
"modified": "2018-12-11 15:49:15.045116",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Education",
|
||||
"name": "Education Settings",
|
||||
|
||||
@@ -39,6 +39,27 @@ class Student(Document):
|
||||
if student:
|
||||
frappe.throw(_("Student {0} exist against student applicant {1}").format(student[0][0], self.student_applicant))
|
||||
|
||||
def after_insert(self):
|
||||
"""Create a website user for student creation if not already exists"""
|
||||
if self.user == None:
|
||||
student_user = frappe.get_doc({
|
||||
'doctype':'User',
|
||||
'first_name': self.first_name,
|
||||
'last_name': self.last_name,
|
||||
'email': self.student_email_id,
|
||||
'gender': self.gender,
|
||||
'send_welcome_email': 1,
|
||||
'user_type': 'Website User'
|
||||
})
|
||||
student_user.add_roles("Student", "LMS User")
|
||||
student_user.save()
|
||||
self.user = student_user.name
|
||||
self.save()
|
||||
frappe.publish_realtime('enroll_student_progress', {"progress": [4, 4]}, user=frappe.session.user)
|
||||
update_password_link = student_user.reset_password()
|
||||
print(update_password_link)
|
||||
|
||||
|
||||
def update_applicant_status(self):
|
||||
"""Updates Student Applicant status to Admitted"""
|
||||
if self.student_applicant:
|
||||
|
||||
Reference in New Issue
Block a user