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