perf: Account bulk error prompt

This commit is contained in:
feng
2025-11-19 17:39:58 +08:00
committed by ZhaoJiSen
parent 4cd70efe66
commit 1a3fb2f0db

View File

@@ -5,7 +5,7 @@ from rest_framework import serializers as drf_serializers
from rest_framework.decorators import action
from rest_framework.generics import ListAPIView, CreateAPIView
from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK
from rest_framework.status import HTTP_200_OK, HTTP_400_BAD_REQUEST
from accounts import serializers
from accounts.const import ChangeSecretRecordStatusChoice
@@ -204,10 +204,18 @@ class AssetAccountBulkCreateApi(CreateAPIView):
templates = base_payload.pop("template", None)
assets = self.get_all_assets(base_payload)
if not assets.exists():
raise drf_serializers.ValidationError(_("No valid assets found for account creation."))
error = _("No valid assets found for account creation.")
return Response(
data={
"detail": error,
"code": "no_valid_assets"
},
status=HTTP_400_BAD_REQUEST
)
result = []
errors = []
def handle_one(_payload):
try:
ser = self.get_serializer(data=_payload)