-
Notifications
You must be signed in to change notification settings - Fork 6
/
database_populater.py
23 lines (21 loc) · 1.01 KB
/
database_populater.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import django,sys, os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cts.settings")
django.setup()
from django.contrib.auth.models import User
from complaint.models import Profile, Complaint, CATEGORY_CHOICES
from django.contrib.auth import authenticate, login,logout
import random
def generate_database():
email_domain = sys.argv[4]
for i in range(int(sys.argv[2]),int(sys.argv[3])+1):
i= "{0:0=2d}".format(i)
user_name = sys.argv[1] + str(i)
pass_word = user_name
email = user_name+ '@' + email_domain
user=User.objects.create_user(user_name, password = pass_word, email= email)
Complaint.objects.create(author=user, title= "complaint_"+user_name,
description= "This is a complaint by "+user_name,
status = random.choice([i[0] for i in Complaint.STATUS_CHOICES]),
category = random.choice([i[0] for i in CATEGORY_CHOICES]))
print(user_name)
generate_database()