schon/payments/signals.py
Egor fureunoir Gorbunov 8fb4ca3362 Features: 1) Add type annotations for various models and methods; 2) Introduce refined graphene resolvers to enhance permission handling; 3) Include type checking suppression with # type: ignore for unsupported cases.
Fixes: 1) Correct `urlsafe_base64_encode` decoding logic in tests; 2) Fix queryset access issues in resolvers; 3) Address missing or incorrect imports across multiple files.

Extra: Improve code readability with consistent naming and formatting; Add `# noinspection` annotations to suppress IDE warnings; Update `pyproject.toml` to exclude `drf.py` in MyPy checks.
2025-06-18 16:38:07 +03:00

21 lines
647 B
Python

from django.db.models.signals import post_save
from django.dispatch import receiver
from payments.models import Balance, Transaction
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: # noqa:
instance.process = {"status": "NOGATEWAY"}