fix: apply as mentor even if email template not found
This commit is contained in:
@@ -11,13 +11,18 @@ class LMSMentorRequest(Document):
|
||||
def on_update(self):
|
||||
if self.has_value_changed('status'):
|
||||
template = frappe.db.get_single_value('LMS Settings', 'mentor_request_status_update')
|
||||
email_template = frappe.get_doc('Email Template', template)
|
||||
if not template:
|
||||
return
|
||||
|
||||
email_template = frappe.get_doc('Email Template', template)
|
||||
message = frappe.render_template(email_template.response, {'member_name': self.member_name, 'status': self.status})
|
||||
subject = _('The status of your application has changed.')
|
||||
member_email = frappe.db.get_value("Community Member", self.member, "email")
|
||||
|
||||
if self.status == 'Approved' or self.status == 'Rejected':
|
||||
reviewed_by = frappe.db.get_value('Community Member', self.reviewed_by, 'email')
|
||||
send_email(member_email, [get_course_author(self.course), reviewed_by], subject, message)
|
||||
|
||||
elif self.status == 'Withdrawn':
|
||||
send_email([member_email, get_course_author(self.course)], None, subject, message)
|
||||
|
||||
@@ -65,6 +70,9 @@ def get_course_author(course):
|
||||
|
||||
def send_creation_email(course, member):
|
||||
template = frappe.db.get_single_value('LMS Settings', 'mentor_request_creation')
|
||||
if not template:
|
||||
return
|
||||
|
||||
email_template = frappe.get_doc('Email Template', template)
|
||||
member_name = member.full_name
|
||||
message = frappe.render_template(email_template.response, {'member_name': member_name})
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"livecode_url",
|
||||
"mentor_request_section",
|
||||
"mentor_request_creation",
|
||||
"mentor_request_status_update",
|
||||
"email_sender"
|
||||
@@ -34,12 +35,17 @@
|
||||
"fieldtype": "Data",
|
||||
"label": "Email Sender",
|
||||
"options": "Email"
|
||||
},
|
||||
{
|
||||
"fieldname": "mentor_request_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Mentor Request"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2021-04-19 13:18:40.497636",
|
||||
"modified": "2021-04-21 13:05:38.691336",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
@@ -3,7 +3,7 @@ frappe.ready(() => {
|
||||
frappe.call({
|
||||
'method': 'community.lms.doctype.lms_mentor_request.lms_mentor_request.has_requested',
|
||||
'args': {
|
||||
course: $(".course-title").attr("data-course"),
|
||||
course: decodeURIComponent($(".course-title").attr("data-course")),
|
||||
},
|
||||
'callback': (data) => {
|
||||
if (data.message) {
|
||||
|
||||
Reference in New Issue
Block a user