Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified data populating script #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 131 additions & 40 deletions populate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,46 +42,91 @@ def create_super_user():
except:
print("Error occurred while creating super user")


try:
(deadline, created) = DeadlineModel.objects.get_or_create(deadline_PS2TS = datetime.now(), deadline_TS2PS = datetime.now())
(deadline, created) = DeadlineModel.objects.get_or_create(
deadline_PS2TS = datetime.now(), deadline_TS2PS = datetime.now())
deadline.save()
print("Deadline created")

except:
print("Error occured while creating deadlines")


def create_user(n):
for i in range(n):
(user, created) = User.objects.get_or_create(username="user" + str(random.randint(1, 1000)))
user.set_password('password')
user.save()


def create_user_profile(i, user_type_name):
def create_user_profile(i, user_type_name, application_type, campus):
try:

(mUser, created) = User.objects.get_or_create(
username=user_type_name + str(i),
first_name=user_type_name + str(i),
email=user_type_name + str(i) +"@gmail.com")
mUser.set_password('password')
mUser.save()
fake_phone_number = fake_number_generator()
# default value
campus_type = 0;

if campus == "/goa":
campus_type = 0
elif campus == "/hyd":
campus_type = 1
elif campus == "/pilani":
campus_type = 2

fake_phone_number = fake_number_generator()
if user_type_name == "Student":
user_type = 0
(mUser, created) = User.objects.get_or_create(
username=user_type_name + application_type
+ campus + str(i),
first_name=user_type_name + str(i),
email=user_type_name + campus + str(i) + "@gmail.com")
mUser.set_password('password')
mUser.save()

elif user_type_name == "Supervisor":
user_type = 1
(mUser, created) = User.objects.get_or_create(
username=user_type_name + application_type
+ campus + str(i),
first_name=user_type_name + str(i),
email=user_type_name + campus + str(i) + "@gmail.com")
mUser.set_password('password')
mUser.save()

elif user_type_name == "HOD":
user_type = 2
(mUser, created) = User.objects.get_or_create(
username=user_type_name + application_type
+ campus + str(i),
first_name=user_type_name + str(i),
email=user_type_name + campus + str(i) + "@gmail.com")
mUser.set_password('password')
mUser.save()

elif user_type_name == "AD":
user_type = 3
(mUser, created) = User.objects.get_or_create(
username=user_type_name + application_type
+ campus + str(i),
first_name=user_type_name + str(i),
email=user_type_name + str(i) + "@gmail.com")
mUser.set_password('password')
mUser.save()

elif user_type_name == "PSD":
user_type = 4
(mUser, created) = User.objects.get_or_create(
username=user_type_name + application_type
+ campus + str(i),
first_name=user_type_name + str(i),
email=user_type_name + str(i) + "@gmail.com")
mUser.set_password('password')
mUser.save()

UserProfile.objects.filter(
user=mUser).update(
campus=random.choice(campus_choices),
campus=campus_type,
contact=fake_phone_number,
user_type=user_type
)
Expand All @@ -91,14 +136,15 @@ def create_user_profile(i, user_type_name):
print("Error creating user profile")


def create_ps2tstransfer(n, student_name):
def create_ps2tstransfer(n, student_name, application_type, campus):
for i in range(n):
create_user_profile(i, student_name)
user = User.objects.get(username=student_name + str(i))
create_user_profile(i, student_name, application_type, campus)
user = User.objects.get(username=student_name
+ application_type + campus + str(i))
user_profile = UserProfile.objects.get(user=user)
new_applicant = user_profile
fake_name_supervisor = "Supervisor" + str(i)
fake_name_hod = "HOD" + str(i)
fake_name_supervisor = "Supervisor" + campus + str(i)
fake_name_hod = "HOD" + campus + str(i)
fake_thesis = "Fake text"
fake_org = "Org name "+str(random.randint(1, 1000))
fake_cg = fake_cgpa()
Expand All @@ -122,13 +168,14 @@ def create_ps2tstransfer(n, student_name):
print(str(e))


def create_ts2pstransfer(n, student_name):
def create_ts2pstransfer(n, student_name, application_type, campus):
for i in range(n):
create_user_profile(i+100, student_name)
user = User.objects.get(username=student_name + str(i+100))
create_user_profile(i+100, student_name, application_type, campus)
user = User.objects.get(username=student_name
+ application_type + campus + str(i+100))
user_profile = UserProfile.objects.get(user=user)
new_applicant = user_profile
fake_name_hod = "HOD" + str(i)
fake_name_hod = "HOD" + campus + str(i+100)
fake_org_name = "Org name "+str(random.randint(1, 1000))
fake_reason = "Reason "+str(random.randint(1, 1000))
fake_cg = fake_cgpa()
Expand Down Expand Up @@ -163,31 +210,75 @@ def create_ts2pstransfer(n, student_name):
create_user(5)
print("Created users without userprofiles")

for i in range(20):
create_user_profile(i, "HOD")
print("Created HOD")

for i in range(20):
create_user_profile(i+100, "HOD")
print("Created HOD pt2")

for i in range(20):
create_user_profile(i, "Supervisor")
print("Created Supervisor")

for i in range(20):
create_user_profile(i+100, "Supervisor")
print("Created Supervisor pt2")
for i in range(10):
create_user_profile(i, "HOD", "", "/goa")
print("Created HOD for Goa")

for i in range(10):
create_user_profile(i, "HOD", "", "/hyd")
print("Created HOD for Hyd")

for i in range(10):
create_user_profile(i, "HOD", "", "/pilani")
print("Created HOD for Pilani")

for i in range(10):
create_user_profile(i+100, "HOD", "", "/goa")
print("Created HOD pt2 for Goa")

for i in range(10):
create_user_profile(i+100, "HOD", "", "/hyd")
print("Created HOD pt2 for HYD")

for i in range(10):
create_user_profile(i+100, "HOD", "", "/pilani")
print("Created HOD pt2 for Pilani")

for i in range(10):
create_user_profile(i, "Supervisor", "", "/goa")
print("Created Supervisor for Goa")

for i in range(10):
create_user_profile(i, "Supervisor", "", "/hyd")
print("Created Supervisor for HYD")

for i in range(10):
create_user_profile(i, "Supervisor", "", "/pilani")
print("Created Supervisor for Pilani")

for i in range(10):
create_user_profile(i+100, "Supervisor", "", "/goa")
print("Created Supervisor pt2 for Goa")

for i in range(10):
create_user_profile(i+100, "Supervisor", "", "/hyd")
print("Created Supervisor pt2 for HYD")

for i in range(10):
create_user_profile(i+100, "Supervisor", "", "/pilani")
print("Created Supervisor pt2 for Pilani")

for i in range(3):
create_user_profile(i, "AD")
create_user_profile(i, "AD", "", "")
print("Created AOD")

create_user_profile(1, "PSD")
create_user_profile(1, "PSD", "", "")
print("Created PSD")

create_ps2tstransfer(20, "Student")
print("PS2TS applications created")
create_ps2tstransfer(10, "Student", "/ps2ts", "/goa")
print("PS2TS applications created for Goa")

create_ps2tstransfer(10, "Student", "/ps2ts", "/hyd")
print("PS2TS applications created for HYD")

create_ps2tstransfer(10, "Student", "/ps2ts", "/pilani")
print("PS2TS applications created for Pilani")

create_ts2pstransfer(10, "Student", "/ts2ps", "/goa")
print("TS2PS applications created for Goa")

create_ts2pstransfer(10, "Student", "/ts2ps", "/hyd")
print("TS2PS applications created for HYD")

create_ts2pstransfer(20, "Student")
print("TS2PS applications created")
create_ts2pstransfer(10, "Student", "/ts2ps", "/pilani")
print("TS2PS applications created for Pilani")