chore(template): seed initial global message templates
This commit is contained in:
parent
f7ad36bef8
commit
2637ee864a
116
apps/notification/backend/scripts/init_message_template.py
Normal file
116
apps/notification/backend/scripts/init_message_template.py
Normal file
@ -0,0 +1,116 @@
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
from backend.models.models import MessageTemplateDoc
|
||||
from beanie import init_beanie
|
||||
from motor.motor_asyncio import AsyncIOMotorClient
|
||||
from common.constants.region import UserRegion
|
||||
|
||||
async def main():
|
||||
# connect to MongoDB
|
||||
client = AsyncIOMotorClient("mongodb://localhost:27017")
|
||||
db = client["freeleaps2"] ##name needed to be renamed:: templates? magicleaps?
|
||||
await init_beanie(database=db, document_models=[MessageTemplateDoc])
|
||||
|
||||
|
||||
templates = [
|
||||
## English Version
|
||||
# evaluation result template
|
||||
MessageTemplateDoc(
|
||||
template_id="evaluation_result",
|
||||
tenant_id=None,
|
||||
region=UserRegion.OTHER,
|
||||
subject="Interview Evaluation Result",
|
||||
body="Your interview evaluation result is: {result}",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
# Deadline Reminder - automated reminders before interview deadlines
|
||||
MessageTemplateDoc(
|
||||
template_id="deadline_reminder",
|
||||
tenant_id=None,
|
||||
region=UserRegion.OTHER,
|
||||
subject="Interview Deadline Reminder",
|
||||
body="Reminder: Your {position} interview will end on {deadline}. Please take action.",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
# Deadline Reminder - notifications when interviews are about to expire
|
||||
MessageTemplateDoc(
|
||||
template_id="interview_expiring",
|
||||
tenant_id=None,
|
||||
region=UserRegion.OTHER,
|
||||
subject="Interview Expiring",
|
||||
body="Reminder: Your {position} interview will expire on {expire_time}. Please take action.",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
# Status Update Notification - status changes
|
||||
MessageTemplateDoc(
|
||||
template_id="status_update",
|
||||
tenant_id=None,
|
||||
region=UserRegion.OTHER,
|
||||
subject="Interview Status Update",
|
||||
body="Your {position} interview status has been updated to: {status}",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
# Status Update Notification - interview cancelled
|
||||
MessageTemplateDoc(
|
||||
template_id="interview_cancelled",
|
||||
tenant_id=None,
|
||||
region=UserRegion.OTHER,
|
||||
subject="Interview Cancelled",
|
||||
body="Your {position} interview has been cancelled.",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
## Chinese Version
|
||||
# Evaluation Result Notification
|
||||
MessageTemplateDoc(
|
||||
template_id="evaluation_result",
|
||||
tenant_id="tenantA",
|
||||
region=UserRegion.ZH_CN,
|
||||
subject="面试评估结果通知",
|
||||
body="您的面试评估结果为:{result}",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
# Deadline Reminder - automated reminders before interview deadlines
|
||||
MessageTemplateDoc(
|
||||
template_id="deadline_reminder",
|
||||
tenant_id="tenantA",
|
||||
region=UserRegion.ZH_CN,
|
||||
subject="面试截止提醒",
|
||||
body="提醒:您申请的 {position} 面试将于 {deadline} 截止,请及时处理。",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
# Deadline Reminder - notifications when interviews are about to expire
|
||||
MessageTemplateDoc(
|
||||
template_id="interview_expiring",
|
||||
tenant_id="tenantA",
|
||||
region=UserRegion.ZH_CN,
|
||||
subject="面试即将过期",
|
||||
body="您的 {position} 面试将在 {expire_time} 过期,请尽快完成相关操作。",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
# Status Update Notification - status changes
|
||||
MessageTemplateDoc(
|
||||
template_id="status_update",
|
||||
tenant_id="tenantA",
|
||||
region=UserRegion.ZH_CN,
|
||||
subject="面试状态更新",
|
||||
body="您的 {position} 面试状态已变更为:{status}",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
# Status Update Notification - interview cancelled
|
||||
MessageTemplateDoc(
|
||||
template_id="interview_cancelled",
|
||||
tenant_id="tenantA",
|
||||
region=UserRegion.ZH_CN,
|
||||
subject="面试已取消",
|
||||
body="您的 {position} 面试已被取消。",
|
||||
created_at=datetime.utcnow()
|
||||
),
|
||||
]
|
||||
|
||||
# Insert templates
|
||||
for template in templates:
|
||||
await template.create()
|
||||
print("Templates inserted successfully.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Loading…
Reference in New Issue
Block a user