refactor StatusUpdateView
This commit is contained in:
@@ -350,21 +350,6 @@ class PaymentProcessingService:
|
||||
# Implement any necessary logic to handle a failed payment
|
||||
self._update_transaction_failure()
|
||||
|
||||
# def _update_principal_subscription(self):
|
||||
# # Fetch the subscription object once and use it
|
||||
# print("Inside _update_principal_subscription")
|
||||
# principal_subscription = self.principal_subscription
|
||||
|
||||
# # Update IS_PAID PrincipalSubscription instance
|
||||
# referred_principal_subscription = PrincipalSubscription.objects.get(
|
||||
# id=principal_subscription.id
|
||||
# )
|
||||
# referred_principal_subscription.stripe_customer_id = self.customer_id
|
||||
# referred_principal_subscription.is_paid = True
|
||||
# referred_principal_subscription.save()
|
||||
|
||||
# return referred_principal_subscription.id
|
||||
|
||||
def _update_reward(
|
||||
self,
|
||||
referral_record,
|
||||
|
||||
@@ -7,6 +7,10 @@ from django.contrib import messages
|
||||
from goodtimes import constants
|
||||
from manage_wallets.forms import PrincipalBankAccountVerificationForm
|
||||
from .models import PrincipalBankAccount, Wallet, Transaction, WithdrawalRequest
|
||||
from django.db import transaction
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
"""Wallet Related VIew"""
|
||||
|
||||
@@ -82,20 +86,20 @@ class StatusUpdateView(LoginRequiredMixin, generic.View):
|
||||
print("Request.POST: ", request.POST)
|
||||
if id or message:
|
||||
try:
|
||||
instance = self.model.objects.get(id=id)
|
||||
print("status: ", status)
|
||||
if status == "transferred":
|
||||
print("Hello")
|
||||
bank_account = PrincipalBankAccount.objects.filter(principal=instance.principal)
|
||||
print("bank_account: ", bank_account)
|
||||
for account in bank_account:
|
||||
account.delete()
|
||||
print("Deleted all accounts")
|
||||
|
||||
instance.reply = message
|
||||
instance.status = status
|
||||
instance.save()
|
||||
messages.success(request, self.success_message)
|
||||
with transaction.atomic():
|
||||
instance = self.model.objects.get(id=id)
|
||||
logger.debug("Updating status for ID %s to %s", id, status)
|
||||
print("status: ", status)
|
||||
if status == "transferred":
|
||||
bank_accounts = PrincipalBankAccount.objects.filter(principal=instance.principal)
|
||||
print("bank_accounts: ", bank_accounts)
|
||||
for account in bank_accounts:
|
||||
account.delete()
|
||||
print("Deleted all accounts")
|
||||
instance.reply = message
|
||||
instance.status = status
|
||||
instance.save()
|
||||
messages.success(request, self.success_message)
|
||||
except self.model.DoesNotExist:
|
||||
messages.error(request, "Contact Us entry not found")
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user