-
Notifications
You must be signed in to change notification settings - Fork 4
/
db_populate.py
34 lines (28 loc) · 1.09 KB
/
db_populate.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
from app.models import *
from django.contrib.auth.models import User
from app.views import generate_password
# Clear pre-existing data
users = User.objects.all()
users.delete()
applicants = Applicant.objects.all()
applicants.delete()
recommenders = Recommender.objects.all()
recommenders.delete()
recommendations = Recommendation.objects.all()
recommendations.delete()
# Add applicant with blank application
user1 = User(first_name = "Fake", last_name = "Applicant", email = "[email protected]", username = "[email protected]")
#user1.set_password(generate_password())
user1.set_password('abc123')
user1.save()
applicant1 = Applicant(role=1, user = user1)
applicant1.save()
# Add recommender
user2 = User(first_name = "Fake", last_name = "Recommender", email = "[email protected]", username = "[email protected]")
user2.set_password('abc123')
user2.save()
recommender1 = Recommender(role=1, user = user2)
recommender1.save()
#Add recommendation to link applicant and recommender
recommendation1 = Recommendation(applicant = applicant1, recommender = recommender1)
recommendation1.save()