Init Django-SHOP

This commit is contained in:
2021-02-23 22:57:30 +00:00
parent 8842939839
commit b4a79a6890
109 changed files with 5734 additions and 160 deletions

View File

@@ -0,0 +1,26 @@
import random
from django.core.management.base import BaseCommand
from weirdlittleempire.models import Commodity, CommodityInventory, SmartCard, SmartCardInventory, SmartPhoneVariant, SmartPhoneInventory
class Command(BaseCommand):
help = "Create Inventories for all products using random values."
def handle(self, verbosity, *args, **options):
self.verbosity = verbosity
for commodity in Commodity.objects.all():
CommodityInventory.objects.create(
product=commodity,
quantity=random.randint(0, 15)
)
for smart_card in SmartCard.objects.all():
SmartCardInventory.objects.create(
product=smart_card,
quantity=random.randint(0, 55)
)
for smart_phone in SmartPhoneVariant.objects.all():
SmartPhoneInventory.objects.create(
product=smart_phone,
quantity=random.randint(0, 8)
)
self.stdout.write("Created inventories with random quantities.")