mirror of
https://github.com/Crocmagnon/checkout.git
synced 2024-11-21 23:58:02 +01:00
Generate dummy baskets with no fixed price items
This commit is contained in:
parent
0f0e4f854a
commit
e3bb57396b
2 changed files with 29 additions and 8 deletions
|
@ -75,5 +75,16 @@
|
|||
"unit_price_cents": 290,
|
||||
"display_order": 7
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "purchase.product",
|
||||
"fields": {
|
||||
"created_at": "2022-04-28T16:08:20.471Z",
|
||||
"updated_at": "2022-04-28T16:09:34.003Z",
|
||||
"name": "Tomme de ch\u00e8vre",
|
||||
"image": "",
|
||||
"unit_price_cents": 0,
|
||||
"display_order": 8
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -52,13 +52,23 @@ class Command(BaseCommand):
|
|||
)
|
||||
items = []
|
||||
for product in selected_products:
|
||||
items.append(
|
||||
BasketItem(
|
||||
product=product,
|
||||
basket=basket,
|
||||
quantity=random.randint(1, 3),
|
||||
unit_price_cents=product.unit_price_cents,
|
||||
),
|
||||
)
|
||||
if not product.has_fixed_price:
|
||||
items.append(
|
||||
BasketItem(
|
||||
product=product,
|
||||
basket=basket,
|
||||
quantity=1,
|
||||
unit_price_cents=random.randint(317, 514),
|
||||
),
|
||||
)
|
||||
else:
|
||||
items.append(
|
||||
BasketItem(
|
||||
product=product,
|
||||
basket=basket,
|
||||
quantity=random.randint(1, 3),
|
||||
unit_price_cents=product.unit_price_cents,
|
||||
),
|
||||
)
|
||||
BasketItem.objects.bulk_create(items)
|
||||
return count
|
||||
|
|
Loading…
Reference in a new issue