-
Notifications
You must be signed in to change notification settings - Fork 4
/
PopulateMe.py
79 lines (64 loc) · 2.01 KB
/
PopulateMe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "oschub.settings")
import django
django.setup()
from faker import Faker
import random
from eventreg.models import Event, EventUserData
from SheetMe import getCompletedEvents
def genReg(num=1000):
regList = []
while len(regList) < 1000:
regList.append(
random.choice(["17", "18", "19", "20"])
+ random.choice(["BCE", "MIS", "BEC", "DAF", "BBA"])
+ str(random.randint(1111, 9999))
)
regList = list(set(regList))
return list(set(regList))
def populateEventUserData(num=1000):
fake = Faker()
nameList = [fake.name() for i in range(num + 1)]
regList = genReg()
# Email Generation
emailList = []
for i in range(num):
emailList.append(
nameList[i].split(" ")[0].lower()
+ "."
+ regList[i].lower()
+ "@vitap.ac.in"
)
# Student Data List generation
studentData = []
eventList = []
completedEvents = getCompletedEvents()
events = Event.objects.all()
for event in events:
eventList.append(event.eventName)
for event in [temp for temp in eventList if temp not in completedEvents]:
for eventData in Event.objects.filter(eventName=event):
for i in range(num):
student = [
eventData,
nameList[i],
regList[i],
emailList[i],
True,
random.choice([True, False]),
]
studentData.append(student)
return studentData
if __name__ == "__main__":
modelData = populateEventUserData(500)
for data in modelData:
row = EventUserData(
eventName=data[0],
studentName=data[1],
studentReg=data[2],
studentEmail=data[3],
studentRegistered=data[4],
studentCheckedIn=data[5],
)
row.save()
print("Added data, check database.")