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.
21 lines
647 B
Python
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"}
|