-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulation_script_users.py
47 lines (31 loc) · 985 Bytes
/
population_script_users.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
import string
import random
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fhs_project.settings')
import django
django.setup()
from fhs.models import UserProfile
from django.contrib.auth.models import User
# Add the three special users
def populate_users_special():
f1 = open("users.txt")
line = f1.readline()[: -1]
while len(line) != 0:
name_gend = string.split(line, " ")
name = name_gend[0]
gender = name_gend[1]
theUser = User()
theUser.username = name
theUser.first_name = name
theUser.email = "{}@gmail.com".format(name)
theUser.password = name
theUser.set_password(theUser.password)
theUser.save()
profile = UserProfile()
profile.user = theUser
profile.gender = gender
profile.save()
line = f1.readline()[: -1]
if __name__ == '__main__':
print "Starting FHS user population script..."
populate_users_special()