1045 lines
48 KiB
Python
1045 lines
48 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
global template creator
|
||
"""
|
||
|
||
import asyncio
|
||
import aiohttp
|
||
import json
|
||
import os
|
||
import sys
|
||
from datetime import datetime, timezone, timedelta
|
||
from jose import jwt
|
||
|
||
sys.path.append('.')
|
||
from common.config.app_settings import app_settings
|
||
from webapi.config.site_settings import site_settings
|
||
|
||
class GlobalTemplateCreator:
|
||
def __init__(self):
|
||
# use site_settings to get base_url
|
||
host = 'localhost' if site_settings.SERVER_HOST == '0.0.0.0' else site_settings.SERVER_HOST
|
||
port = site_settings.SERVER_PORT
|
||
self.base_url = f"http://{host}:{port}/api/notification"
|
||
self.admin_token = None
|
||
self.templates = []
|
||
|
||
print(f"🔧 use config: {self.base_url}")
|
||
|
||
def generate_test_tokens(self):
|
||
"""generate test JWT token"""
|
||
secret_key = app_settings.SECRET_KEY
|
||
algorithm = "HS256"
|
||
|
||
# generate admin token
|
||
admin_payload = {
|
||
"id": "test_admin_user",
|
||
"role": 8, # ADMINISTRATOR = 8
|
||
"tenant_id": None,
|
||
"exp": datetime.now(timezone.utc) + timedelta(hours=1)
|
||
}
|
||
admin_token = jwt.encode(admin_payload, secret_key, algorithm=algorithm)
|
||
|
||
# generate tenant token
|
||
tenant_payload = {
|
||
"id": "test_tenant_user",
|
||
"role": 2, # BUSINESS = 2
|
||
"tenant_id": "test_tenant_user",
|
||
"exp": datetime.now(timezone.utc) + timedelta(hours=1)
|
||
}
|
||
tenant_token = jwt.encode(tenant_payload, secret_key, algorithm=algorithm)
|
||
|
||
print("\n🔑 generated test tokens:")
|
||
print("=" * 60)
|
||
print(f"Admin Token: {admin_token}")
|
||
print(f"Tenant Token: {tenant_token}")
|
||
print(f"Secret Key: {secret_key[:20]}...")
|
||
print("=" * 60)
|
||
|
||
return admin_token, tenant_token
|
||
|
||
async def get_admin_token(self):
|
||
"""get admin token"""
|
||
print("🔑 get admin token...")
|
||
|
||
try:
|
||
admin_token, tenant_token = self.generate_test_tokens()
|
||
self.admin_token = admin_token
|
||
|
||
if self.admin_token:
|
||
print("✅ admin token retrieved successfully")
|
||
return True
|
||
else:
|
||
print("❌ admin token retrieval failed")
|
||
return False
|
||
except Exception as e:
|
||
print(f"❌ error getting token: {e}")
|
||
return False
|
||
|
||
async def create_template(self, template_data):
|
||
"""create template"""
|
||
if not self.admin_token:
|
||
print("❌ no valid admin token")
|
||
return False
|
||
|
||
headers = {"Authorization": f"Bearer {self.admin_token}"}
|
||
|
||
async with aiohttp.ClientSession() as session:
|
||
async with session.post(
|
||
f"{self.base_url}/admin/global_templates/create",
|
||
json=template_data,
|
||
headers=headers
|
||
) as response:
|
||
print(f"status code: {response.status}")
|
||
response_text = await response.text()
|
||
print(f"response: {response_text}")
|
||
|
||
if response.status == 201:
|
||
print(f"✅ template '{template_data['template_id']}' created successfully")
|
||
return True
|
||
else:
|
||
print(f"❌ template '{template_data['template_id']}' creation failed: {response_text}")
|
||
return False
|
||
|
||
async def create_assessment_result_template(self):
|
||
"""create assessment result notification template"""
|
||
print("\n📝 create assessment result notification template...")
|
||
|
||
# Chinese version (region: 1)
|
||
template_data_cn = {
|
||
"template_id": "assessment_result_notification",
|
||
"region": 1,
|
||
"subject": "笔试结果 - {candidate_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">尊敬的 {candidate_name},</h2>
|
||
|
||
<p>感谢您参加我们的笔试考核。以下是您的评估结果:</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📊 评估详情</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>候选人姓名:</strong>{candidate_name}</li>
|
||
<li><strong>评估日期:</strong>{assessment_date}</li>
|
||
<li><strong>评估时长:</strong>{duration_minutes} 分钟</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #e7f3ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">🔍 执行结果</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>执行状态:</strong>{execution_status}</li>
|
||
<li><strong>执行时间:</strong>{execution_time} 毫秒</li>
|
||
<li><strong>测试用例通过率:</strong>{test_cases_passed}/{total_test_cases} ({pass_rate}%)</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">⚠️ 执行错误信息</h3>
|
||
<p>{execution_errors}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📈 详细结果</h3>
|
||
<p>{detailed_results}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">🎯 评估结论</h3>
|
||
<p>{assessment_conclusion}</p>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>如有任何疑问,请联系我们的技术团队:</p>
|
||
<p><strong>邮箱:</strong>{tech_support_email}</p>
|
||
<p><strong>电话:</strong>{tech_support_phone}</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>祝好!<br>{company_name} 技术团队</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
# English version (region: 0)
|
||
template_data_en = {
|
||
"template_id": "assessment_result_notification",
|
||
"region": 0,
|
||
"subject": "Assessment Result - {candidate_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">Dear {candidate_name},</h2>
|
||
|
||
<p>Thank you for participating in our assessment. Here are your evaluation results:</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📊 Assessment Details</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Candidate Name: </strong>{candidate_name}</li>
|
||
<li><strong>Assessment Date: </strong>{assessment_date}</li>
|
||
<li><strong>Duration: </strong>{duration_minutes} minutes</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #e7f3ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">🔍 Execution Results</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Execution Status: </strong>{execution_status}</li>
|
||
<li><strong>Execution Time: </strong>{execution_time} milliseconds</li>
|
||
<li><strong>Test Cases Passed: </strong>{test_cases_passed}/{total_test_cases} ({pass_rate}%)</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">⚠️ Execution Errors</h3>
|
||
<p>{execution_errors}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📈 Detailed Results</h3>
|
||
<p>{detailed_results}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">🎯 Assessment Conclusion</h3>
|
||
<p>{assessment_conclusion}</p>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>If you have any questions, please contact our technical team:</p>
|
||
<p><strong>Email: </strong>{tech_support_email}</p>
|
||
<p><strong>Phone: </strong>{tech_support_phone}</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>Best regards,<br>{company_name} Technical Team</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
success_cn = await self.create_template(template_data_cn)
|
||
success_en = await self.create_template(template_data_en)
|
||
|
||
return success_cn and success_en
|
||
|
||
async def create_deadline_reminder_template(self):
|
||
"""create deadline reminder template"""
|
||
print("\n📝 create deadline reminder template...")
|
||
|
||
# Chinese version (region: 1)
|
||
template_data_cn = {
|
||
"template_id": "deadline_reminder",
|
||
"region": 1,
|
||
"subject": "截止期限提醒 - {task_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">尊敬的 {recipient_name},</h2>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0; border-left: 4px solid #ffc107;">
|
||
<h3 style="color: #856404; margin-top: 0;">⚠️ 截止期限提醒</h3>
|
||
<p>您有一个任务即将到期:</p>
|
||
</div>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📋 任务详情</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>任务名称:</strong>{task_name}</li>
|
||
<li><strong>任务描述:</strong>{task_description}</li>
|
||
<li><strong>截止日期:</strong>{deadline_date}</li>
|
||
<li><strong>剩余时间:</strong>{remaining_time}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #e7f3ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">⏰ 时间信息</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>当前时间:</strong>{current_time}</li>
|
||
<li><strong>截止时间:</strong>{deadline_time}</li>
|
||
<li><strong>剩余天数:</strong>{days_remaining} 天</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📝 任务要求</h3>
|
||
<p>{task_requirements}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">🔗 相关链接</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>任务详情:</strong><a href="{task_url}" style="color: #007bff;">{task_url}</a></li>
|
||
<li><strong>提交入口:</strong><a href="{submission_url}" style="color: #007bff;">{submission_url}</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>请务必在截止日期前完成相关任务。如有任何问题,请联系:</p>
|
||
<p><strong>邮箱:</strong>{contact_email}</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>谢谢!<br>{company_name} 团队</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
# English version (region: 0)
|
||
template_data_en = {
|
||
"template_id": "deadline_reminder",
|
||
"region": 0,
|
||
"subject": "Deadline Reminder - {task_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">Dear {recipient_name},</h2>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0; border-left: 4px solid #ffc107;">
|
||
<h3 style="color: #856404; margin-top: 0;">⚠️ Deadline Reminder</h3>
|
||
<p>You have a task that is approaching its deadline:</p>
|
||
</div>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📋 Task Details</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Task Name: </strong>{task_name}</li>
|
||
<li><strong>Task Description: </strong>{task_description}</li>
|
||
<li><strong>Deadline Date: </strong>{deadline_date}</li>
|
||
<li><strong>Time Remaining: </strong>{remaining_time}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #e7f3ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">⏰ Time Information</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Current Time: </strong>{current_time}</li>
|
||
<li><strong>Deadline Time: </strong>{deadline_time}</li>
|
||
<li><strong>Days Remaining: </strong>{days_remaining} days</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📝 Task Requirements</h3>
|
||
<p>{task_requirements}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">🔗 Related Links</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Task Details: </strong><a href="{task_url}" style="color: #007bff;">{task_url}</a></li>
|
||
<li><strong>Submission Portal: </strong><a href="{submission_url}" style="color: #007bff;">{submission_url}</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>Please ensure to complete the related task before the deadline. If you have any questions, please contact:</p>
|
||
<p><strong>Email: </strong>{contact_email}</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>Thank you!<br>{company_name} Team</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
success_cn = await self.create_template(template_data_cn)
|
||
success_en = await self.create_template(template_data_en)
|
||
|
||
return success_cn and success_en
|
||
|
||
async def create_interview_status_update_template(self):
|
||
"""create interview status update template"""
|
||
print("\n📝 create interview status update template...")
|
||
|
||
# Chinese version (region: 1)
|
||
template_data_cn = {
|
||
"template_id": "interview_status_update",
|
||
"region": 1,
|
||
"subject": "面试状态更新 - {candidate_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">尊敬的 {candidate_name},</h2>
|
||
|
||
<p>您的面试状态已更新:</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">👤 候选人信息</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>姓名:</strong>{candidate_name}</li>
|
||
<li><strong>应聘职位:</strong>{position_name}</li>
|
||
<li><strong>申请编号:</strong>{application_id}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #e7f3ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📊 状态更新</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>当前状态:</strong>{current_status}</li>
|
||
<li><strong>更新日期:</strong>{update_date}</li>
|
||
<li><strong>更新时间:</strong>{update_time}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📋 状态详情</h3>
|
||
<p>{status_details}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">📅 下一步安排</h3>
|
||
<p>{next_steps}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">⏰ 重要时间</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>面试时间:</strong>{interview_time}</li>
|
||
<li><strong>面试地点:</strong>{interview_location}</li>
|
||
<li><strong>面试官:</strong>{interviewer_name}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📞 联系方式</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>面试官邮箱:</strong>{interviewer_email}</li>
|
||
<li><strong>面试官电话:</strong>{interviewer_phone}</li>
|
||
<li><strong>公司地址:</strong>{company_address}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>请及时查看并准备相关材料。</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>祝面试顺利!<br>{company_name} 人力资源部</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
# English version (region: 0)
|
||
template_data_en = {
|
||
"template_id": "interview_status_update",
|
||
"region": 0,
|
||
"subject": "Interview Status Update - {candidate_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">Dear {candidate_name},</h2>
|
||
|
||
<p>Your interview status has been updated:</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">👤 Candidate Information</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Name: </strong>{candidate_name}</li>
|
||
<li><strong>Position Applied: </strong>{position_name}</li>
|
||
<li><strong>Application ID: </strong>{application_id}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #e7f3ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📊 Status Update</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Current Status: </strong>{current_status}</li>
|
||
<li><strong>Update Date: </strong>{update_date}</li>
|
||
<li><strong>Update Time: </strong>{update_time}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📋 Status Details</h3>
|
||
<p>{status_details}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">📅 Next Steps</h3>
|
||
<p>{next_steps}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">⏰ Important Times</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Interview Time: </strong>{interview_time}</li>
|
||
<li><strong>Interview Location: </strong>{interview_location}</li>
|
||
<li><strong>Interviewer: </strong>{interviewer_name}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📞 Contact Information</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Interviewer Email: </strong>{interviewer_email}</li>
|
||
<li><strong>Interviewer Phone: </strong>{interviewer_phone}</li>
|
||
<li><strong>Company Address: </strong>{company_address}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>Please review and prepare relevant materials in a timely manner.</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>Good luck with your interview!<br>{company_name} Human Resources Department</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
success_cn = await self.create_template(template_data_cn)
|
||
success_en = await self.create_template(template_data_en)
|
||
|
||
return success_cn and success_en
|
||
|
||
async def create_welcome_email_template(self):
|
||
"""create welcome email template"""
|
||
print("\n📝 create welcome email template...")
|
||
|
||
# Chinese version (region: 1)
|
||
template_data_cn = {
|
||
"template_id": "welcome_email",
|
||
"region": 1,
|
||
"subject": "欢迎加入 {company_name} - {new_employee_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">亲爱的 {new_employee_name},</h2>
|
||
|
||
<div style="background-color: #d4edda; padding: 20px; border-radius: 5px; margin: 20px 0; text-align: center;">
|
||
<h1 style="color: #155724; margin: 0;">🎉 欢迎加入 {company_name}!</h1>
|
||
</div>
|
||
|
||
<p>我们很高兴地通知您,您已成功加入我们的团队。以下是您的入职信息:</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">👤 员工信息</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>姓名:</strong>{new_employee_name}</li>
|
||
<li><strong>员工编号:</strong>{employee_id}</li>
|
||
<li><strong>部门:</strong>{department}</li>
|
||
<li><strong>职位:</strong>{position}</li>
|
||
<li><strong>入职日期:</strong>{start_date}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #e7f3ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">🏢 公司信息</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>公司名称:</strong>{company_name}</li>
|
||
<li><strong>公司地址:</strong>{company_address}</li>
|
||
<li><strong>联系电话:</strong>{company_phone}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📋 入职安排</h3>
|
||
<p>{onboarding_schedule}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">🔑 系统访问信息</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>邮箱:</strong>{email_address}</li>
|
||
<li><strong>初始密码:</strong>{initial_password}</li>
|
||
<li><strong>系统登录地址:</strong><a href="{system_login_url}" style="color: #007bff;">{system_login_url}</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">📚 重要资源</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>员工手册:</strong><a href="{employee_handbook_url}" style="color: #007bff;">{employee_handbook_url}</a></li>
|
||
<li><strong>培训材料:</strong><a href="{training_materials_url}" style="color: #007bff;">{training_materials_url}</a></li>
|
||
<li><strong>公司政策:</strong><a href="{company_policies_url}" style="color: #007bff;">{company_policies_url}</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">👥 联系人</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>直属经理:</strong>{manager_name} ({manager_email})</li>
|
||
<li><strong>HR联系人:</strong>{hr_contact_name} ({hr_contact_email})</li>
|
||
<li><strong>IT支持:</strong>{it_support_email}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">🎯 第一周安排</h3>
|
||
<p>{first_week_schedule}</p>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>如有任何问题,请随时联系我们。</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>再次欢迎您的加入!<br>{company_name} 团队</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
# English version (region: 0)
|
||
template_data_en = {
|
||
"template_id": "welcome_email",
|
||
"region": 0,
|
||
"subject": "Welcome to {company_name} - {new_employee_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">Dear {new_employee_name},</h2>
|
||
|
||
<div style="background-color: #d4edda; padding: 20px; border-radius: 5px; margin: 20px 0; text-align: center;">
|
||
<h1 style="color: #155724; margin: 0;">🎉 Welcome to {company_name}!</h1>
|
||
</div>
|
||
|
||
<p>We are pleased to inform you that you have successfully joined our team. Here is your onboarding information:</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">👤 Employee Information</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Name: </strong>{new_employee_name}</li>
|
||
<li><strong>Employee ID: </strong>{employee_id}</li>
|
||
<li><strong>Department: </strong>{department}</li>
|
||
<li><strong>Position: </strong>{position}</li>
|
||
<li><strong>Start Date: </strong>{start_date}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #e7f3ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">🏢 Company Information</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Company Name: </strong>{company_name}</li>
|
||
<li><strong>Company Address: </strong>{company_address}</li>
|
||
<li><strong>Contact Phone: </strong>{company_phone}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📋 Onboarding Schedule</h3>
|
||
<p>{onboarding_schedule}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">🔑 System Access Information</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Email: </strong>{email_address}</li>
|
||
<li><strong>Initial Password: </strong>{initial_password}</li>
|
||
<li><strong>System Login URL: </strong><a href="{system_login_url}" style="color: #007bff;">{system_login_url}</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">📚 Important Resources</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Employee Handbook: </strong><a href="{employee_handbook_url}" style="color: #007bff;">{employee_handbook_url}</a></li>
|
||
<li><strong>Training Materials: </strong><a href="{training_materials_url}" style="color: #007bff;">{training_materials_url}</a></li>
|
||
<li><strong>Company Policies: </strong><a href="{company_policies_url}" style="color: #007bff;">{company_policies_url}</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">👥 Contacts</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Direct Manager: </strong>{manager_name} ({manager_email})</li>
|
||
<li><strong>HR Contact: </strong>{hr_contact_name} ({hr_contact_email})</li>
|
||
<li><strong>IT Support: </strong>{it_support_email}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">🎯 First Week Schedule</h3>
|
||
<p>{first_week_schedule}</p>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>If you have any questions, please feel free to contact us.</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>Welcome aboard!<br>{company_name} Team</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
success_cn = await self.create_template(template_data_cn)
|
||
success_en = await self.create_template(template_data_en)
|
||
|
||
return success_cn and success_en
|
||
|
||
async def create_password_reset_template(self):
|
||
"""create password reset email template"""
|
||
print("\n📝 create password reset email template...")
|
||
|
||
# Chinese version (region: 1)
|
||
template_data_cn = {
|
||
"template_id": "password_reset_email",
|
||
"region": 1,
|
||
"subject": "密码重置请求 - {user_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">尊敬的 {user_name},</h2>
|
||
|
||
<p>我们收到了您的密码重置请求。</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">🔐 重置信息</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>用户名:</strong>{user_name}</li>
|
||
<li><strong>邮箱:</strong>{email_address}</li>
|
||
<li><strong>请求时间:</strong>{request_time}</li>
|
||
<li><strong>请求IP:</strong>{request_ip}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">🔗 重置链接</h3>
|
||
<p><a href="{reset_link}" style="color: #007bff; text-decoration: none; padding: 10px 20px; background-color: #007bff; color: white; border-radius: 5px; display: inline-block;">点击重置密码</a></p>
|
||
<p style="font-size: 12px; color: #666;">或复制链接:{reset_link}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">⚠️ 重要提醒</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li>• 此链接将在 {expiry_hours} 小时后失效</li>
|
||
<li>• 请勿将此链接分享给他人</li>
|
||
<li>• 如果您没有请求重置密码,请忽略此邮件</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📱 验证码</h3>
|
||
<p style="font-size: 24px; font-weight: bold; text-align: center; letter-spacing: 5px; color: #155724;">{verification_code}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">🔒 安全提示</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li>• 请使用强密码(包含大小写字母、数字和特殊字符)</li>
|
||
<li>• 不要使用与其他账户相同的密码</li>
|
||
<li>• 定期更换密码以确保账户安全</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>如有任何问题,请联系技术支持:</p>
|
||
<p><strong>邮箱:</strong>{support_email}</p>
|
||
<p><strong>电话:</strong>{support_phone}</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>谢谢!<br>{company_name} 技术支持团队</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
# English version (region: 0)
|
||
template_data_en = {
|
||
"template_id": "password_reset_email",
|
||
"region": 0,
|
||
"subject": "Password Reset Request - {user_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">Dear {user_name},</h2>
|
||
|
||
<p>We have received your password reset request.</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">🔐 Reset Information</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Username: </strong>{user_name}</li>
|
||
<li><strong>Email: </strong>{email_address}</li>
|
||
<li><strong>Request Time: </strong>{request_time}</li>
|
||
<li><strong>Request IP: </strong>{request_ip}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">🔗 Reset Link</h3>
|
||
<p><a href="{reset_link}" style="color: #007bff; text-decoration: none; padding: 10px 20px; background-color: #007bff; color: white; border-radius: 5px; display: inline-block;">Click to Reset Password</a></p>
|
||
<p style="font-size: 12px; color: #666;">Or copy the link: {reset_link}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">⚠️ Important Reminder</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li>• This link will expire in {expiry_hours} hours</li>
|
||
<li>• Please do not share this link with others</li>
|
||
<li>• If you did not request a password reset, please ignore this email</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📱 Verification Code</h3>
|
||
<p style="font-size: 24px; font-weight: bold; text-align: center; letter-spacing: 5px; color: #155724;">{verification_code}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">🔒 Security Tips</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li>• Please use a strong password (containing uppercase and lowercase letters, numbers, and special characters)</li>
|
||
<li>• Do not use the same password as other accounts</li>
|
||
<li>• Change your password regularly to ensure account security</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||
<p>If you have any questions, please contact technical support:</p>
|
||
<p><strong>Email: </strong>{support_email}</p>
|
||
<p><strong>Phone: </strong>{support_phone}</p>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>Thank you!<br>{company_name} Technical Support Team</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
success_cn = await self.create_template(template_data_cn)
|
||
success_en = await self.create_template(template_data_en)
|
||
|
||
return success_cn and success_en
|
||
|
||
async def create_account_verification_template(self):
|
||
"""create account verification email template"""
|
||
print("\n📝 create account verification email template...")
|
||
|
||
# Chinese version (region: 1)
|
||
template_data_cn = {
|
||
"template_id": "account_verification_email",
|
||
"region": 1,
|
||
"subject": "账号验证 - {user_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">尊敬的 {user_name},</h2>
|
||
|
||
<p>感谢您注册 {company_name} 的账户。请验证您的邮箱地址以完成注册。</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">👤 账户信息</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>用户名:</strong>{user_name}</li>
|
||
<li><strong>邮箱地址:</strong>{email_address}</li>
|
||
<li><strong>注册时间:</strong>{registration_time}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">🔗 验证链接</h3>
|
||
<p><a href="{verification_link}" style="color: #007bff; text-decoration: none; padding: 10px 20px; background-color: #007bff; color: white; border-radius: 5px; display: inline-block;">点击验证邮箱</a></p>
|
||
<p style="font-size: 12px; color: #666;">或复制链接:{verification_link}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📱 验证码</h3>
|
||
<p style="font-size: 24px; font-weight: bold; text-align: center; letter-spacing: 5px; color: #155724;">{verification_code}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">⏰ 验证期限</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>验证链接有效期:</strong>{expiry_hours} 小时</li>
|
||
<li><strong>请在 {expiry_time} 前完成验证</strong></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">✅ 验证步骤</h3>
|
||
<ol style="padding-left: 20px;">
|
||
<li>点击上面的验证链接,或</li>
|
||
<li>在登录页面输入验证码:<strong>{verification_code}</strong></li>
|
||
</ol>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">⚠️ 安全提醒</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li>• 请勿将验证码分享给他人</li>
|
||
<li>• 如果您没有注册账户,请忽略此邮件</li>
|
||
<li>• 验证完成后,请立即登录并修改初始密码</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📞 需要帮助?</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>技术支持:</strong>{support_email}</li>
|
||
<li><strong>客服热线:</strong>{support_phone}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">🎯 验证完成后,您将可以:</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li>• 访问所有功能</li>
|
||
<li>• 接收重要通知</li>
|
||
<li>• 管理个人信息</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>谢谢!<br>{company_name} 团队</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
# English version (region: 0)
|
||
template_data_en = {
|
||
"template_id": "account_verification_email",
|
||
"region": 0,
|
||
"subject": "Account Verification - {user_name}",
|
||
"body": """<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||
<div style="text-align: center; margin-bottom: 20px;">
|
||
<img src="{company_logo}" alt="{company_name} Logo" style="max-height: 60px;">
|
||
</div>
|
||
|
||
<h2 style="color: #333;">Dear {user_name},</h2>
|
||
|
||
<p>Thank you for registering an account with {company_name}. Please verify your email address to complete your registration.</p>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">👤 Account Information</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Username: </strong>{user_name}</li>
|
||
<li><strong>Email Address: </strong>{email_address}</li>
|
||
<li><strong>Registration Time: </strong>{registration_time}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">🔗 Verification Link</h3>
|
||
<p><a href="{verification_link}" style="color: #007bff; text-decoration: none; padding: 10px 20px; background-color: #007bff; color: white; border-radius: 5px; display: inline-block;">Click to Verify Email</a></p>
|
||
<p style="font-size: 12px; color: #666;">Or copy the link: {verification_link}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">📱 Verification Code</h3>
|
||
<p style="font-size: 24px; font-weight: bold; text-align: center; letter-spacing: 5px; color: #155724;">{verification_code}</p>
|
||
</div>
|
||
|
||
<div style="background-color: #cce5ff; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #004085; margin-top: 0;">⏰ Verification Period</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Verification Link Valid: </strong>{expiry_hours} hours</li>
|
||
<li><strong>Please complete verification before {expiry_time}</strong></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">✅ Verification Steps</h3>
|
||
<ol style="padding-left: 20px;">
|
||
<li>Click the verification link above, or</li>
|
||
<li>Enter the verification code on the login page: <strong>{verification_code}</strong></li>
|
||
</ol>
|
||
</div>
|
||
|
||
<div style="background-color: #fff3cd; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #856404; margin-top: 0;">⚠️ Security Reminder</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li>• Please do not share the verification code with others</li>
|
||
<li>• If you did not register an account, please ignore this email</li>
|
||
<li>• After verification, please log in immediately and change your initial password</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #007bff; margin-top: 0;">📞 Need Help?</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li><strong>Technical Support: </strong>{support_email}</li>
|
||
<li><strong>Customer Service: </strong>{support_phone}</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="background-color: #d4edda; padding: 15px; border-radius: 5px; margin: 20px 0;">
|
||
<h3 style="color: #155724; margin-top: 0;">🎯 After verification, you will be able to:</h3>
|
||
<ul style="list-style: none; padding: 0;">
|
||
<li>• Access all features</li>
|
||
<li>• Receive important notifications</li>
|
||
<li>• Manage personal information</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
|
||
<p>Thank you!<br>{company_name} Team</p>
|
||
</div>
|
||
</div>"""
|
||
}
|
||
|
||
success_cn = await self.create_template(template_data_cn)
|
||
success_en = await self.create_template(template_data_en)
|
||
|
||
return success_cn and success_en
|
||
|
||
async def create_all_templates(self):
|
||
"""create all templates"""
|
||
print("🚀 start creating global templates...")
|
||
print("=" * 60)
|
||
|
||
# get admin token
|
||
await self.get_admin_token()
|
||
|
||
# create all templates
|
||
templates_to_create = [
|
||
self.create_assessment_result_template,
|
||
self.create_deadline_reminder_template,
|
||
self.create_interview_status_update_template,
|
||
self.create_welcome_email_template,
|
||
self.create_password_reset_template,
|
||
self.create_account_verification_template
|
||
]
|
||
|
||
success_count = 0
|
||
for create_func in templates_to_create:
|
||
if await create_func():
|
||
success_count += 1
|
||
|
||
print(f"\n✅ templates created successfully! created {success_count}/{len(templates_to_create)} templates")
|
||
|
||
# display created template list
|
||
print("\n📋 created templates list:")
|
||
template_names = [
|
||
"assessment_result_notification - 评估结果通知",
|
||
"deadline_reminder - 截止期限提醒",
|
||
"interview_status_update - 面试状态更新",
|
||
"welcome_email - 欢迎邮件",
|
||
"password_reset_email - 密码重置邮件",
|
||
"account_verification_email - 账号验证邮件"
|
||
]
|
||
|
||
for i, name in enumerate(template_names, 1):
|
||
print(f"{i}. {name}")
|
||
|
||
async def main():
|
||
"""main function"""
|
||
creator = GlobalTemplateCreator()
|
||
await creator.create_all_templates()
|
||
|
||
if __name__ == "__main__":
|
||
asyncio.run(main()) |