-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpasses_seed_script.py
50 lines (40 loc) · 1.01 KB
/
passes_seed_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
from faker import Faker
import yaml
import random
fake = Faker()
passes = []
pass_types = [
'Standard',
'Senior Lifetime',
'Senior Annual',
'Access',
'Military',
'4th Grade',
'Volunteer'
]
pass_costs = [45.00, 80.00, 75.00, 30.00, 25.00, 100.00, 95.00]
pass_ids = []
for i in range(1, 301):
if i < 10:
pass_ids.append(f'00000{i}')
elif 9 < i < 100:
pass_ids.append(f'0000{i}')
else:
pass_ids.append(f'000{i}')
for i in range(1, 301):
new_pass = {}
new_pass['model'] = 'nps_django.pass'
new_pass['pk'] = i
new_pass['fields'] = {
'type': random.choice(pass_types),
'pass_id': pass_ids.pop(),
'passholder_primary': i,
'expiration_date': fake.date_between(start_date="-1y", end_date="+1y"),
'zip_code': fake.postcode(),
'email': fake.ascii_safe_email(),
'phone_num': fake.phone_number(),
'cost': random.choice(pass_costs)
}
passes.append(new_pass)
with open('passes.yaml', 'w') as outfile:
yaml.dump(passes, outfile, default_flow_style=False)