-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopulate.py
More file actions
47 lines (39 loc) · 1.32 KB
/
populate.py
File metadata and controls
47 lines (39 loc) · 1.32 KB
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
from app import app, db, site_name, site_tagline, ts
import datetime
from time import sleep
from models import *
now = datetime.now()
nowiso = now.isoformat()
one_day = timedelta(days=1)
# creates participants for a raffle
def pp_create_participants(raffle_id):
for i in range (0,50):
participant_phone = "+{}".format(random.randint(12345678910,19876543210))
partipant = create_participant(participant_phone, raffle_id)
print "50 participats added per raffle."
# creates 3 raffles: active, closed and upcoming
def pp_create_raffles():
# create 2 closed raffles:
dt_start = datetime.now() - one_day
dt_end = datetime.now()
raffle = create_raffle("Prize closed raffle", dt_start, dt_end)
print "Closed raffle added."
sleep(5)
# create 2 upcoming raffles:
dt_start = datetime.now() + one_day + one_day
dt_end = datetime.now() + one_day + one_day + one_day + one_day
raffle = create_raffle("Prize upcoming raffle", dt_start, dt_end)
print "Upcoming raffle added."
sleep(5)
# create an active raffle:
dt_start = datetime.now()
dt_end = datetime.now() + one_day
raffle = create_raffle("Prize active raffle", dt_start, dt_end)
print "Added raffle added."
if __name__ == "__main__":
print "Populating..."
pp_create_raffles()
raffles = get_raffles()
for raffle in raffles:
pp_create_participants(raffle.id)
print "Ready!"