Skip to content

Commit

Permalink
added limit support for assets import
Browse files Browse the repository at this point in the history
  • Loading branch information
UdaySagar-Git committed Mar 12, 2024
1 parent 77cba1b commit 1959e28
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions care/facility/api/viewsets/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@ def bulk_upsert(self, request, *args, **kwargs):
if "location" not in request.data:
raise ValidationError({"location": "Location is required"})

limit = request.data.get("limit", None)
if limit is None:
limit = float("inf")
if len(request.data["assets"]) > limit:
raise ValidationError(
{"assets": f"Maximum of {limit} assets can be created at once"}
)

assets = request.data.get("assets", [])
location = request.data.get("location")
errors = []
Expand Down

0 comments on commit 1959e28

Please sign in to comment.