schon/payments/signals.py
Egor fureunoir Gorbunov b92e7e28f1 Features: 1) Add new email content translations for ru_RU, zh_Hans, and ro_RO locales; 2) Update "balance deposit" and general email-related translations across multiple languages;
Fixes: 1) Correct inconsistent formatting in translation strings; 2) Fix placeholders in email templates for better accuracy;

Extra: Update `.gitignore` to include `.env` file exclusion.
2025-06-22 20:18:19 +03:00

27 lines
1,018 B
Python

from django.db.models.signals import post_save
from django.dispatch import receiver
from payments.models import Balance, Transaction
from payments.utils.emailing import balance_deposit_email
from vibes_auth.models import User
@receiver(post_save, sender=User)
def create_balance_on_user_creation_signal(instance, created, **_kwargs):
if created:
Balance.objects.create(user=instance)
@receiver(post_save, sender=Transaction)
def process_transaction_changes(instance, created, **_kwargs):
if created:
try:
gateway = object()
gateway.process_transaction(instance)
except Exception as e: # noqa:
instance.process = {"status": "NOGATEWAY", "error": str(e)}
if not created:
if "success" in str(instance.process).lower() and "notify" in str(instance.process).lower():
balance_deposit_email.delay(instance.uuid)
if "fail" in str(instance.process).lower() and "notify" in str(instance.process).lower():
pass