Refactor VerifyPaymentView to include checks for payment status and user authorization. Update logging level in settings.py to suppress certain logs during testing. Add comprehensive tests for device management in DeviceAPITestCase.
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 2m23s

This commit is contained in:
2025-04-11 17:06:28 +05:00
parent b6303a2c23
commit b8d9f5cf87
4 changed files with 89 additions and 5 deletions

View File

@ -108,6 +108,13 @@ class VerifyPaymentView(StaffEditorPermissionMixin, generics.UpdateAPIView):
payment = self.get_object()
data = request.data
user = request.user
print("logged in user", user)
print("Payment user", payment.user)
if payment.paid:
return Response(
{"message": "Payment has already been verified."},
status=status.HTTP_400_BAD_REQUEST,
)
if payment.user != user and not user.is_superuser:
return Response(
{"message": "You are not authorized to verify this payment."},
@ -156,7 +163,7 @@ class VerifyPaymentView(StaffEditorPermissionMixin, generics.UpdateAPIView):
)
else:
return Response(
{"message": "Payment verification FAILED using [{method}]."}
{"message": f"Payment verification FAILED using [{method}]."}
)
def process_wallet_payment(self, user, payment):