Merge pull request #640 from pateljannat/registration-email
feat: batch registration confirmation email
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
"student_details_section",
|
||||
"student",
|
||||
"payment",
|
||||
"confirmation_email_sent",
|
||||
"column_break_oduu",
|
||||
"student_name",
|
||||
"username"
|
||||
@@ -52,12 +53,18 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Payment",
|
||||
"options": "LMS Payment"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "confirmation_email_sent",
|
||||
"fieldtype": "Check",
|
||||
"label": "Confirmation Email Sent"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-09-12 16:46:41.042810",
|
||||
"modified": "2023-10-09 17:09:50.481794",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Batch Student",
|
||||
|
||||
@@ -8,9 +8,17 @@ import json
|
||||
from frappe import _
|
||||
from datetime import timedelta
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import cint, format_date, format_datetime
|
||||
from frappe.utils import (
|
||||
cint,
|
||||
format_date,
|
||||
format_datetime,
|
||||
add_to_date,
|
||||
getdate,
|
||||
get_datetime,
|
||||
)
|
||||
from lms.lms.utils import get_lessons, get_lesson_index, get_lesson_url
|
||||
from lms.www.utils import get_quiz_details, get_assignment_details
|
||||
from frappe.email.doctype.email_template.email_template import get_email_template
|
||||
|
||||
|
||||
class LMSBatch(Document):
|
||||
@@ -22,6 +30,7 @@ class LMSBatch(Document):
|
||||
self.validate_duplicate_assessments()
|
||||
self.validate_membership()
|
||||
self.validate_timetable()
|
||||
self.send_confirmation_mail()
|
||||
|
||||
def validate_duplicate_students(self):
|
||||
students = [row.student for row in self.students]
|
||||
@@ -55,6 +64,43 @@ class LMSBatch(Document):
|
||||
)
|
||||
)
|
||||
|
||||
def send_confirmation_mail(self):
|
||||
for student in self.students:
|
||||
|
||||
if not student.confirmation_email_sent:
|
||||
self.send_mail(student)
|
||||
student.confirmation_email_sent = 1
|
||||
|
||||
def send_mail(self, student):
|
||||
subject = _("Enrollment Confirmation for the Next Training Batch")
|
||||
template = "batch_confirmation"
|
||||
custom_template = frappe.db.get_single_value(
|
||||
"LMS Settings", "batch_confirmation_template"
|
||||
)
|
||||
|
||||
args = {
|
||||
"student_name": student.student_name,
|
||||
"start_time": self.start_time,
|
||||
"start_date": self.start_date,
|
||||
"medium": self.medium,
|
||||
"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=student.student,
|
||||
subject=subject,
|
||||
template=template if not custom_template else None,
|
||||
content=content if custom_template else None,
|
||||
args=args,
|
||||
header=[subject, "green"],
|
||||
retry=3,
|
||||
)
|
||||
|
||||
def validate_membership(self):
|
||||
for course in self.courses:
|
||||
for student in self.students:
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"portal_course_creation",
|
||||
"section_break_szgq",
|
||||
"send_calendar_invite_for_evaluations",
|
||||
"batch_confirmation_template",
|
||||
"column_break_2",
|
||||
"allow_student_progress",
|
||||
"payment_section",
|
||||
@@ -176,7 +177,7 @@
|
||||
{
|
||||
"fieldname": "section_break_szgq",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Class Settings"
|
||||
"label": "Batch Settings"
|
||||
},
|
||||
{
|
||||
"fieldname": "signup_settings_tab",
|
||||
@@ -186,6 +187,7 @@
|
||||
{
|
||||
"fieldname": "mentor_request_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"hidden": 1,
|
||||
"label": "Mentor Request"
|
||||
},
|
||||
{
|
||||
@@ -253,12 +255,18 @@
|
||||
"fieldname": "apply_rounding",
|
||||
"fieldtype": "Check",
|
||||
"label": "Apply Rounding on Equivalent"
|
||||
},
|
||||
{
|
||||
"fieldname": "batch_confirmation_template",
|
||||
"fieldtype": "Link",
|
||||
"label": "Batch Confirmation Template",
|
||||
"options": "Email Template"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2023-09-11 21:56:39.996898",
|
||||
"modified": "2023-10-09 17:27:28.615355",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
38
lms/templates/emails/batch_confirmation.html
Normal file
38
lms/templates/emails/batch_confirmation.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<p>
|
||||
{{ _("Dear ") }} {{ student_name }},
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
{{ _("I am pleased to inform you that your enrollment for the upcoming training batch has been successfully processed. Congratulations!") }}
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
<b>
|
||||
{{ _("Important Details:") }}
|
||||
</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>{{ _("Batch Start Date:") }}</b> {{ frappe.utils.format_date(start_date, "medium") }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>{{ _("Medium:") }}</b> {{ medium }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>{{ _("Timings:") }}</b> {{ frappe.utils.format_time(start_time, "hh:mm a") }}
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
{{ _("Visit the following link to view your ") }}
|
||||
<a href="/batches/{{ name }}">{{ _("Batch Details") }}</a>
|
||||
</p>
|
||||
<p>
|
||||
{{ _("If you have any questions or require assistance, feel free to contact us.") }}
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
{{ _("Best Regards") }}
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user