feat: certification email
This commit is contained in:
@@ -6,12 +6,41 @@ from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import add_years, nowdate
|
||||
from lms.lms.utils import is_certified
|
||||
from frappe.email.doctype.email_template.email_template import get_email_template
|
||||
|
||||
|
||||
class LMSCertificate(Document):
|
||||
def validate(self):
|
||||
self.validate_duplicate_certificate()
|
||||
|
||||
def after_insert(self):
|
||||
self.send_mail()
|
||||
|
||||
def send_mail(self):
|
||||
subject = _("Congratulations on getting certified!")
|
||||
template = "certification"
|
||||
custom_template = frappe.db.get_single_value("LMS Settings", "certification_template")
|
||||
|
||||
args = {
|
||||
"student_name": self.member_name,
|
||||
"course_name": self.course,
|
||||
"course_title": frappe.db.get_value("LMS Course", self.course, "title"),
|
||||
"certificate_name": self.name,
|
||||
}
|
||||
|
||||
if custom_template:
|
||||
email_template = get_email_template(custom_template, args)
|
||||
subject = email_template.get("subject")
|
||||
content = email_template.get("message")
|
||||
frappe.sendmail(
|
||||
recipients=self.member,
|
||||
subject=subject,
|
||||
template=template if not custom_template else None,
|
||||
content=content if custom_template else None,
|
||||
args=args,
|
||||
header=[subject, "green"],
|
||||
)
|
||||
|
||||
def validate_duplicate_certificate(self):
|
||||
certificates = frappe.get_all(
|
||||
"LMS Certificate",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"is_onboarding_complete",
|
||||
"column_break_zdel",
|
||||
"livecode_url",
|
||||
"certification_template",
|
||||
"course_settings_section",
|
||||
"search_placeholder",
|
||||
"column_break_iqxy",
|
||||
@@ -186,7 +187,7 @@
|
||||
{
|
||||
"fieldname": "section_break_szgq",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Class Settings"
|
||||
"label": "Batch Settings"
|
||||
},
|
||||
{
|
||||
"fieldname": "signup_settings_tab",
|
||||
@@ -316,12 +317,18 @@
|
||||
"fieldname": "show_dashboard",
|
||||
"fieldtype": "Check",
|
||||
"label": "Dashboard"
|
||||
},
|
||||
{
|
||||
"fieldname": "certification_template",
|
||||
"fieldtype": "Link",
|
||||
"label": "Certificate Email Template",
|
||||
"options": "Email Template"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2023-10-30 16:42:58.994359",
|
||||
"modified": "2023-11-01 22:38:38.380325",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
21
lms/templates/emails/certification.html
Normal file
21
lms/templates/emails/certification.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<p>
|
||||
{{ _("Dear ") }} {{ student_name }},
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
{{ _("I am delighted to inform you that you have successfully earned your certification for the {0} course. Congratulations!").format(frappe.bold(course_title)) }}
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
{{ _("With this certification, you can now showcase your updated skills and share your achievement with your colleagues and on LinkedIn. To access your certificate, please click on the link provided below.") }}
|
||||
</p>
|
||||
<br>
|
||||
<a href="/courses/{{ course_name }}/{{certificate_name}}">{{ _("Certificate Link") }}</a>
|
||||
<br>
|
||||
<p>
|
||||
{{ _("Once again, congratulations on this significant accomplishment.")}}
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
{{ _("Best Regards") }}
|
||||
</p>
|
||||
Reference in New Issue
Block a user