-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpopulation_script.py
226 lines (178 loc) · 10.7 KB
/
population_script.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'eventmaker.settings')
import django
import datetime
import pytz
django.setup()
from eventmakerapp.models import UserProfile, Event, Comment, Like
from django.contrib.auth.models import User
def populate():
#Populate Users
Users = {"first_name":["John","Cara","Bill","Matthew","Kira","Charlie","Euan","Emma","Ben","Jamie"],
"last_name" :["Smith","johnson","Williams","Brown","Jones","Miller","Davis","Hunter","Rodriguez","Martinez"],
"is_business":[True,True,True,False,False,False,False,False,False,False],
"description":["Hi everyone! I'm John, an exchange student from Wisconsin, USA. I love taking long hikes in the mountains. Looking forward to having lots of fun in Glasgow!",
"Cara here. You can call me C. Did you know that the first oranges weren't actually orange? Studying BioChem second year. Insta: caraJ",
"How ye daein?",
"'You miss 100% of the shots you don't take. - Wayne Gretzky' - Michael Scott",
"Anybody wanna join me for MCFLY on the 29th???? DON'T WANNA GO ALONE",
"Hello, my name is Charlie. I am currently studying English Literature. I look forward to joining your event",
"",
"Favourite colour: Pink. Favourite animal: Fox. Favourite food: Avocado Sushi. Favourite band: Twenty One Pilots",
"",
"J.Martinez, reporting on deck!",],
"picture":[None,"pp_cara.jpg","pp_bill.jpg",None,"pp_kira.jpg",None,None,None,"pp_ben.jpg","pp_jamie.jpg"],}
for i in range(10):
#create or get User built into django
user, created = User.objects.get_or_create(username=Users["first_name"][i])
#fore make password for testing purpose
user.set_password('pass' + Users["first_name"][i])
user.save()
#call funtion to make the Userprofile in custom model
add_User(user,
Users["first_name"][i],
Users["last_name"][i],
Users["is_business"][i],
Users["description"][i],
Users["picture"][i])
#Populate Events
Date = [datetime.datetime(2021, 7, 1, 18, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 4, 29, 19, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 5, 1, 20, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 7, 29, 19, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 2, 12, 18, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 1, 3, 18, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 7, 21, 12, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 7, 1, 18, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 3, 29, 15, 0, 0, 0,tzinfo=pytz.UTC),
datetime.datetime(2021, 12, 23, 13, 0, 0, 0,tzinfo=pytz.UTC),
]
Pictures = ["Hive.jpg",
"mcfly.jpg",
"nick-cave-bad-seeds.jpg",
"MusicShow.jpeg",
"karaoke.jpg",
"Happy-hour.jpg",
"chess.jpg",
"Ceilidh.jpg",
"funrun.jpg",
"kelvingrove.jpg"]
#add
description = ["Situated in the heart of the West End, Glasgow University Union is a unique venue rich in history. With its grand architecture and original period features, the building boasts a versatility that can see it transformed from a corporate setting into a spectacular and magnificent wedding venue. With the capacity to hold large dinner events, conferences and weddings, at the Glasgow University Union we possess a wealth of knowledge in hosting academic, corporate and private functions. "
,"MCFLY at The Hydro. The SSE Hydro is a multi-purpose indoor arena located within the Scottish Event Campus in Glasgow, Scotland. The arena was initially named The Hydro after its main sponsor Scottish Hydro Electric. The arena was officially opened on 30 September 2013, with a concert by Rod Stewart."
,"NICK CAVE AND THE BAD SEEDS at the hydro. The SSE Hydro is a multi-purpose indoor arena located within the Scottish Event Campus in Glasgow, Scotland. The arena was initially named The Hydro after its main sponsor Scottish Hydro Electric. The arena was officially opened on 30 September 2013, with a concert by Rod Stewart."
,"Some bands playing at our weekly music show"
,"Come and give it a go. karaoke night at the Bar"
,"All drinks 30% off come down with your friends and have a laugh"
,"Amature Chess tournemnt, just have fun"
,"Good laugh for everyone, don't need to know any dances just come along"
,"Raise Money for charity and get sponsored to do a 5k run!"
,"Cleen up the park with us!"
, ]
hosts = ["John","Cara","Bill","John","Cara","Bill","John","Cara","Bill","John",]
Eventhosts = []
for i in range(10):
#get userobj hosting from username to be the host
user = User.objects.get(username=hosts[i])
Eventhosts.append(user)
Events = { "title":["Hive Thursday", "MCFLY", "NICK CAVE AND THE BAD SEEDS", "Music Show", "Open Mic Night", "Happy Hour", "Chess Tournement", "Highland Ceilidh", "Fun Run" , "Litter Picking in Kelvingrove Park"],
"description": description,
"locationName":["Glasgow University Union","Glasgow Hydro","Glasgow Hydro","Bar Name","karaoke Bar","Bar Name","Glasgow University","Glasgow University","Glasgow Argyle Street","Kelvingrove Park"],##
"entry":["", "", "", "", "", "", "", "", "", "", ],
"location":["55.872530, -4.284912", "55.860044, -4.285217", "55.860044, -4.285217", "55.860044, -4.285217", "55.874865, -4.292925", "55.874865, -4.292925", "55.871796, -4.288292", "55.871483, -4.288543", "55.858129, -4.254747", "55.867991, -4.283774",],
"picture": Pictures,
"time": Date,
"price":[4, 25, 40, 3, 0, 0, 6, 5, 5, 0],
"host":Eventhosts}
#call add event
for i in range(10):
add_event( Events["title"][i],
Events["description"][i],
Events["locationName"][i],##
Events["entry"][i],
Events["location"][i],
Events["picture"][i],
Events["time"][i],
Events["price"][i],
Events["host"][i],
)
#All comments None represent no comments left
UserComments = {"John" : ["Looks Great!", None, "I am Going next week!", None, "love it!", None, "anyone else going", None, "is this one again next week", None, ]
,"Cara" : [None, "WOW", None, "cant wait", None, "love it", None, "looks amazing!", "Lets go", None, ]
,"Bill" : [None, "Loved this place been before", None, "Never Been but looks good", None, "coming next week", None, "i am bringing everyone", None, ":)", ]
,"Matthew" : ["coming tomorrow", None, "can you bring a bag", None, "whats the phone number for this place", None, "anyone want to come with me?", None, "add me on snap if your going sc_fakeuser", None, ]
,"Kira" : ["is there a locker", None, None, None, None, None, None, None, None, None, ]
,"Charlie" : [None, "is this anygood", "expensive!?", "is there food", None, "can you bring in food", None, "Look so good", None, "great to see this", ]
,"Euan" : ["might come along", None, "I want to do this for my birthday", "can you come early", None, "awesome", None, "Never coming again", None, "WOW", ]
,"Emma" : ["Loved it", None, "Cant wait to do this again", None, "I cant drive", None, "How do you play", None, "Woop", None, ]
,"Ben" : ["Crazy", None, "was not bad", None, "who else is coming", None, "anyone want to come with me", None, "look good", None, ]
,"Jamie": ["Best Night ever", None, "Nice", None, "CANT WAIT", None, "I DONT LIKE CHESS", None, None, "THIS IS SO GOOD, FINALLY IT WILL BE CLEAN", ]
}
#Populate Comments
for name in UserComments:
for i in range(10):
if UserComments[name][i] != None:
#call add comment with user, event and comment message
E = Event.objects.get(title=Events["title"][i])
U = User.objects.get(username=name)
add_comment(E, U, UserComments[name][i])
UserLikes = {"John" : []
,"Cara" : []
,"Bill" : []
,"Matthew" : []
,"Kira" : []
,"Charlie" : []
,"Euan" : []
,"Emma" : []
,"Ben" : []
,"Jamie": []
}
#Bulid 2d array for likes
Count = 9
for name in UserLikes:
for i in range(10):
if i >= Count:
UserLikes[name].append(False)
else:
UserLikes[name].append(True)
Count = Count - 1
#Populate Like
for name in UserLikes:
for i in range(10):
if UserLikes[name][i] != False:
E = Event.objects.get(title=Events["title"][i])
U = User.objects.get(username=name)
add_likes(E, U)
#create user in database
def add_User(user,first_name,last_name,is_business,description,picture=None):
U = UserProfile.objects.get_or_create(
user=user,
first_name=first_name,
last_name=last_name,
is_business=is_business,
description=description,
picture=picture)
def add_event(title,description,locationName,entry,location,picture,time,price,host): ##
E = Event.objects.get_or_create(
title=title,
description=description,
locationName=locationName,##
entry=entry,
location=location,
picture=picture,
time=time,
price=price,
host=host)
def add_comment(event, user, data):
C = Comment.objects.get_or_create(
event=event,
user=user,
data=data)
def add_likes(event,user):
L = Like.objects.get_or_create(
event=event,
user=user)
if __name__ == '__main__':
print("Population Eventmaker with population script...")
populate()