From 5254bdb964e917c18cb0198d029b43d38d8fc472 Mon Sep 17 00:00:00 2001 From: "ahmed.mujtaba" Date: Wed, 16 Sep 2026 16:40:40 +0500 Subject: [PATCH] offer_Format1 --- backend/offer_email_template/template.py | 95 +++++++++++++++++++++++ backend/offer_email_template/template2.py | 0 2 files changed, 95 insertions(+) create mode 100644 backend/offer_email_template/template.py create mode 100644 backend/offer_email_template/template2.py diff --git a/backend/offer_email_template/template.py b/backend/offer_email_template/template.py new file mode 100644 index 0000000..1a8198e --- /dev/null +++ b/backend/offer_email_template/template.py @@ -0,0 +1,95 @@ +from html import escape + + +def _text(value): + """Escape user-entered text and keep its line breaks ("Maymar Office\\nOr\\nHead Office").""" + if value in (None, ""): + return "" + return "
".join(escape(line.strip()) for line in str(value).splitlines()) + + +def _salary(value): + if value in (None, ""): + return "" + try: + amount = float(str(value).replace(",", "")) + return f"PKR {amount:,.0f}" + except (TypeError, ValueError): + return _text(value) + + +def _recruiter_names(recruiter_names): + names = [str(n).strip() for n in (recruiter_names or []) if n and str(n).strip()] + if not names: + return "" + if len(names) == 1: + return escape(names[0]) + if len(names) == 2: + return f"{escape(names[0])} & {escape(names[1])}" + return ", ".join(escape(n) for n in names[:-1]) + f" & {escape(names[-1])}" + + +def _package_row(label, value, bold=False): + cell = "border:1px solid #000000;padding:4px 8px;vertical-align:top;" + shown = f"{value}" if bold else value + return ( + "" + f'{label}' + f'{shown}' + "" + ) + + +def render_offer_email_body( + candidate_name, + offered_position, + cadre, + company_name, + monthly_gross_salary, + subsidized_services, + probation_period, + notice_period, + location, + timings, + recruiter_names, +): + """Annexure J - Offer Email Format as an Outlook-safe HTML body: inline styles + and a bordered table only, no