fix: align context_vars and SAMPLE_CONTEXTS with actual runtime context keys
TEMPLATE_TYPES context_vars showed wrong placeholder names to admins (e.g. 'amount' instead of 'formatted_amount', 'balance' instead of 'formatted_balance'). SAMPLE_CONTEXTS had mismatched keys causing test emails to render with empty values. Fixed types: balance_topup, balance_change, autopay_success, autopay_insufficient_funds, daily_debit, daily_insufficient_funds, referral_bonus.
This commit is contained in:
@@ -37,7 +37,7 @@ TEMPLATE_TYPES = [
|
||||
'zh': '余额充值通知',
|
||||
'ua': 'Сповіщення про поповнення балансу',
|
||||
},
|
||||
'context_vars': ['amount', 'balance'],
|
||||
'context_vars': ['formatted_amount', 'formatted_balance', 'amount_rubles', 'new_balance_rubles'],
|
||||
},
|
||||
{
|
||||
'type': 'balance_change',
|
||||
@@ -48,7 +48,7 @@ TEMPLATE_TYPES = [
|
||||
'zh': '余额变动通知',
|
||||
'ua': 'Сповіщення про зміну балансу',
|
||||
},
|
||||
'context_vars': ['amount', 'balance'],
|
||||
'context_vars': ['formatted_amount', 'formatted_balance', 'amount_rubles', 'new_balance_rubles'],
|
||||
},
|
||||
{
|
||||
'type': 'subscription_expiring',
|
||||
@@ -128,7 +128,7 @@ TEMPLATE_TYPES = [
|
||||
'zh': '自动续费成功通知',
|
||||
'ua': 'Сповіщення про успішний автоплатіж',
|
||||
},
|
||||
'context_vars': ['amount', 'balance', 'new_end_date'],
|
||||
'context_vars': ['formatted_amount', 'amount_rubles', 'new_expires_at'],
|
||||
},
|
||||
{
|
||||
'type': 'autopay_failed',
|
||||
@@ -160,7 +160,7 @@ TEMPLATE_TYPES = [
|
||||
'zh': '自动续费余额不足通知',
|
||||
'ua': 'Сповіщення про нестачу коштів для автоплатежу',
|
||||
},
|
||||
'context_vars': ['required_amount', 'balance'],
|
||||
'context_vars': ['required_amount', 'current_balance'],
|
||||
},
|
||||
{
|
||||
'type': 'daily_debit',
|
||||
@@ -171,7 +171,7 @@ TEMPLATE_TYPES = [
|
||||
'zh': '每日扣费通知',
|
||||
'ua': 'Сповіщення про добове списання',
|
||||
},
|
||||
'context_vars': ['amount', 'balance'],
|
||||
'context_vars': ['formatted_amount', 'formatted_balance', 'amount_rubles', 'new_balance_rubles'],
|
||||
},
|
||||
{
|
||||
'type': 'daily_insufficient_funds',
|
||||
@@ -187,7 +187,7 @@ TEMPLATE_TYPES = [
|
||||
'zh': '每日扣费余额不足通知',
|
||||
'ua': 'Сповіщення про нестачу коштів для добового списання',
|
||||
},
|
||||
'context_vars': ['required_amount', 'balance'],
|
||||
'context_vars': ['required_amount', 'current_balance'],
|
||||
},
|
||||
{
|
||||
'type': 'ban_notification',
|
||||
@@ -236,7 +236,7 @@ TEMPLATE_TYPES = [
|
||||
'zh': '推荐奖励通知',
|
||||
'ua': 'Сповіщення про нарахування реферального бонусу',
|
||||
},
|
||||
'context_vars': ['amount', 'referral_name'],
|
||||
'context_vars': ['formatted_bonus', 'bonus_rubles', 'referral_name'],
|
||||
},
|
||||
{
|
||||
'type': 'referral_registered',
|
||||
@@ -388,15 +388,15 @@ SAMPLE_CONTEXTS: dict[str, dict[str, Any]] = {
|
||||
'subscription_expired': {},
|
||||
'subscription_renewed': {'new_end_date': '2025-02-28', 'tariff_name': 'Premium'},
|
||||
'subscription_activated': {'tariff_name': 'Premium', 'end_date': '2025-02-28'},
|
||||
'autopay_success': {'formatted_amount': '300.00 ₽', 'formatted_balance': '200.00 ₽', 'new_end_date': '2025-02-28'},
|
||||
'autopay_success': {'formatted_amount': '300.00 ₽', 'amount_rubles': 300, 'new_expires_at': '2025-02-28'},
|
||||
'autopay_failed': {'reason': 'Card declined'},
|
||||
'autopay_insufficient_funds': {'formatted_required': '300.00 ₽', 'formatted_balance': '50.00 ₽'},
|
||||
'autopay_insufficient_funds': {'required_amount': '300.00 ₽', 'current_balance': '50.00 ₽'},
|
||||
'daily_debit': {'formatted_amount': '10.00 ₽', 'formatted_balance': '490.00 ₽'},
|
||||
'daily_insufficient_funds': {'formatted_required': '10.00 ₽', 'formatted_balance': '5.00 ₽'},
|
||||
'daily_insufficient_funds': {'required_amount': '10.00 ₽', 'current_balance': '5.00 ₽'},
|
||||
'ban_notification': {'reason': 'Violation of terms of service'},
|
||||
'unban_notification': {},
|
||||
'warning_notification': {'message': 'Please review our terms of service'},
|
||||
'referral_bonus': {'formatted_amount': '100.00 ₽', 'referral_name': 'John'},
|
||||
'referral_bonus': {'formatted_bonus': '100.00 ₽', 'bonus_rubles': 100, 'referral_name': 'John'},
|
||||
'referral_registered': {'referral_name': 'John'},
|
||||
'traffic_reset': {'traffic_limit': '100 GB'},
|
||||
'payment_received': {'formatted_amount': '500.00 ₽', 'payment_method': 'YooKassa'},
|
||||
|
||||
Reference in New Issue
Block a user