def handle(self, *args, **options): if len(Company.objects.all()) < 5: company_names = [ "charity", "grocery", "assignment", "industry", "negotiation", "mud", "performance", "committee", "patience", "meaning", "student", "teaching", "message", "agency", "county", "inspector", "president", "fortune", "instruction", "television", "estate", "inflation", "refrigerator", "examination", "organization", "death", "teacher", "warning", "idea", "psychology", "establishment", "mode", "session", "politics", "analysis", "transportation", "difference", "variation", "version", "information", "addition", "dinner", "homework", "protection", "property", "writing", "hotel", "possession", "problem" ] company_titles = ["LLC", "Inc", "Co", "Corp", "Ltd"] names = [ "Jacob", "Michael", "Matthew", "Joshua", "Christopher", "Nicholas", "Andrew", "Joseph", "Daniel", "Tyler", "William", "Brandon", "Ryan", "John", "Zachary", "David", "Anthony", "James", "Justin", "Alexander", "Jonathan", "Christian", "Austin", "Dylan", "Ethan", "Benjamin", "Noah", "Samuel", "Robert", "Nathan", "Cameron", "Kevin", "Thomas", "Jose", "Hunter", "Jordan", "Kyle", "Caleb", "Jason", "Logan", "Aaron", "Eric", "Brian", "Gabriel", "Adam", "Jack", "Isaiah", "Juan", "Luis", "Connor" ] last_names = [ "Smith", "Johnson", "Williams", "Brown", "Jones", "Miller", "Davis", "Garcia", "Rodriguez", "Wilson", "Martinez", "Anderson", "Taylor", "Thomas", "Hernandez", "Moore", "Martin", "Jackson", "Thompson", "White", "Lopez", "Lee", "Gonzalez", "Harris", "Clark", "Lewis", "Robinson", "Walker", "Perez", "Hall", "Young", "Allen", "Sanchez", "Wright", "King", "Scott", "Green", "Baker", "Adams", "Nelson", "Hill", "Ramirez", "Campbell", "Mitchell", "Roberts", "Carter", "Phillips", "Evans", "Turner", "Torres" ] for index, company in enumerate(company_names): print("*****Creating users for : " + company + " - " + str(index) + " of " + str(len(company_names)) + "*****") company = Company.create(company.capitalize() + " " + random.choice(company_titles)) for name in range(1, random.randrange(1, 20)): fullname = names[name] + " " + random.choice( last_names) + " " + str(random.randrange(1, 9999)) user = PerpayUser.objects.create_user(username=fullname, email=fullname + "@gmail.com", password="******", company=company.id) for i in range(1, random.randrange(1, 20)): Payment.create(random.randrange(1, 5000), user) else: self.stdout.write(self.style.SUCCESS('Skipped Database fill'))
def handle(self, *args, **options): # company = Company.objects.get_or_create("AdminCompany") if len(Company.objects.all()) ==0: company = Company.create("AdminCompany") user=get_user_model() user = PerpayUser.objects.create_superuser(username="******",email="*****@*****.**",password="******",company=company.id) for i in range(1,random.randrange(1,10)): Payment.create(random.randrange(1,5000),user) self.stdout.write(self.style.SUCCESS('Successfully created Admin user and Company')) else: self.stdout.write(self.style.SUCCESS('Skipped initial setup'))
def payment(request): if request.method == 'POST': body = json.loads(request.body) payment = Payment.create(**body) responese = {'status': 200, 'payment': payment.serialize()} return JsonResponse(responese, status=200) response = { 'status': 400, 'message': 'Invalid request method', } return JsonResponse(response, status=400)