diff options
Diffstat (limited to 'app/dispatch/management/commands')
| -rw-r--r-- | app/dispatch/management/commands/insert_fake_data.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/app/dispatch/management/commands/insert_fake_data.py b/app/dispatch/management/commands/insert_fake_data.py index 0919181..5d4203d 100644 --- a/app/dispatch/management/commands/insert_fake_data.py +++ b/app/dispatch/management/commands/insert_fake_data.py @@ -1,6 +1,6 @@ from django.core.management.base import BaseCommand, CommandError from django.contrib.auth import get_user_model -from dispatch.models import Company, Load +from dispatch.models import Customer, Load from faker import Faker import random @@ -35,15 +35,15 @@ class Command(BaseCommand): self.end_date = options['enddate'] self.start_date = options['startdate'] - company_ids = [] + customer_ids = [] user_ids = [] for i in range(0, options['companies']): - co = self.fake_company() + co = self.fake_customer() # We're going to hold the model IDs in memory to access randomly # later on - company_ids.append(co.pk) + customer_ids.append(co.pk) for i in range(0, options['users']): u = self.fake_user() @@ -51,37 +51,36 @@ class Command(BaseCommand): user_ids.append(u.pk) for i in range(0, options['loads']): - co_id = company_ids[random.randint(0, len(company_ids)-1)] - co = Company.objects.get(pk=co_id) + co_id = customer_ids[random.randint(0, len(customer_ids)-1)] + co = Customer.objects.get(pk=co_id) u_id = user_ids[random.randint(0, len(user_ids)-1)] u = User.objects.get(pk=u_id) l = self.fake_load(u, co) - def fake_company(self): - new_company = Company( + def fake_customer(self): + new_customer = Customer( name=self.fake.company(), address=self.fake.address(), phone_number=self.fake.msisdn(), email_address=self.fake.company_email(), contact_name=self.fake.name(), ) - new_company.save() - return new_company + new_customer.save() + return new_customer def fake_load(self, usr, co): fake_description = "{}-{} {} {}K".format( self.fake.month(), self.fake.day_of_month(), self.fake.license_plate(), random.randint(5, 50)) - print(fake_description) new_load = Load( user=usr, # Because that's going to be random enough # load_number=self.fake.license_plate(), # description=self.fake.sentence(nb_words=6), description=fake_description, - company=co, + customer=co, amount=random.randint(150,2500), delivered_to=self.fake.city(), ) |
