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.
This commit is contained in:
+8
-1
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user