From f464e2856b5a49946ab484b60cd471d2dc947e51 Mon Sep 17 00:00:00 2001 From: Horilla Date: Wed, 26 Feb 2025 16:59:24 +0530 Subject: [PATCH] [UPDT] BASE: Send mail preview function updated --- base/forms.py | 19 ++++++++++++ employee/not_in_out_dashboard.py | 13 +++++--- employee/templates/employee/send_mail.html | 31 +++++++++++-------- employee/urls.py | 4 +-- .../pipeline_components/send_mail.html | 6 ++-- recruitment/urls.py | 2 +- recruitment/views/actions.py | 2 +- 7 files changed, 53 insertions(+), 24 deletions(-) diff --git a/base/forms.py b/base/forms.py index 1f3a1f14e..451b44e25 100644 --- a/base/forms.py +++ b/base/forms.py @@ -2233,6 +2233,25 @@ class MailTemplateForm(ModelForm): } return mail_data + def get_employee_template_language(self): + mail_data = { + "Receiver|Full name": "instance.get_full_name", + "Sender|Full name": "self.get_full_name", + "Receiver|Recruitment": "instance.recruitment_id", + "Sender|Recruitment": "self.recruitment_id", + "Receiver|Company": "instance.get_company", + "Sender|Company": "self.get_company", + "Receiver|Job position": "instance.get_job_position", + "Sender|Job position": "self.get_job_position", + "Receiver|Email": "instance.get_mail", + "Sender|Email": "self.get_mail", + "Receiver|Employee Type": "instance.get_employee_type", + "Sender|Employee Type": "self.get_employee_type", + "Receiver|Work Type": "instance.get_work_type", + "Sender|Work Type": "self.get_work_type", + } + return mail_data + class MultipleApproveConditionForm(ModelForm): CONDITION_CHOICE = [ diff --git a/employee/not_in_out_dashboard.py b/employee/not_in_out_dashboard.py index 4c22782a5..9e90da820 100644 --- a/employee/not_in_out_dashboard.py +++ b/employee/not_in_out_dashboard.py @@ -16,6 +16,7 @@ from django.http import HttpResponse, JsonResponse from django.shortcuts import render from base.backends import ConfiguredEmailBackend +from base.forms import MailTemplateForm from base.methods import export_data, generate_pdf from base.models import HorillaMailTemplate from employee.filters import EmployeeFilter @@ -83,12 +84,16 @@ def send_mail(request, emp_id=None): if emp_id: employee = Employee.objects.get(id=emp_id) employees = Employee.objects.all() - templates = HorillaMailTemplate.objects.all() return render( request, "employee/send_mail.html", - {"employee": employee, "templates": templates, "employees": employees}, + { + "employee": employee, + "templates": templates, + "employees": employees, + "searchWords": MailTemplateForm().get_employee_template_language(), + }, ) @@ -172,13 +177,13 @@ def get_template(request, emp_id): @login_required -def get_mail_preview(request, emp_id=None): +def get_mail_preview(request): """ This method is used to return the mail template """ body = request.GET.get("body") template_bdy = template.Template(body) - # candidate_id = request.GET.get("candidate_id") + emp_id = request.GET.get("emp_id") if emp_id: employee = Employee.objects.get(id=emp_id) context = template.Context( diff --git a/employee/templates/employee/send_mail.html b/employee/templates/employee/send_mail.html index cdecc3463..75b4d779d 100644 --- a/employee/templates/employee/send_mail.html +++ b/employee/templates/employee/send_mail.html @@ -57,6 +57,9 @@ +
+ {% trans "Hint: Type '{' to get sender or receiver data" %} +