File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed
Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change 11import datetime
2+ import json
23import random
34import string
45
78import names
89import PyMatcha .models .user as user_module
910from PyMatcha .errors import ConflictError
11+ from PyMatcha .models .tag import Tag
1012
1113User = user_module .User
14+ get_user = user_module .get_user
1215
1316
1417def gen_datetime (min_year : int = 1900 , max_year : int = datetime .datetime .now ().year ) -> datetime .datetime :
@@ -57,7 +60,7 @@ def populate_users():
5760 username = first_name + end_of_username
5861
5962 try :
60- User .create (
63+ u = User .create (
6164 first_name = first_name ,
6265 last_name = last_name ,
6366 email = email .lower (),
@@ -68,7 +71,6 @@ def populate_users():
6871 orientation = orientation ,
6972 birthdate = birthdate .date (),
7073 geohash = geohash ,
71- tags = "" , # TODO: Change to a real random tag generation
7274 heat_score = 0 ,
7375 is_online = random .choice ([True , False ]),
7476 date_joined = date_joined ,
@@ -77,6 +79,13 @@ def populate_users():
7779 is_confirmed = True ,
7880 confirmed_on = datetime .datetime .utcnow (),
7981 )
82+ with open ("tags.json" ) as handle :
83+ json_list = json .load (handle )
84+ u = get_user (username )
85+ tags = random .sample (json_list , 5 )
86+
87+ for tag in tags :
88+ Tag .create (name = tag , user_id = u .id )
8089 except ConflictError :
8190 pass # Pass on the conflict error, this user wont be created because the username is taken. Who cares ?
8291 # TODO: Add images
Original file line number Diff line number Diff line change 1+ [
2+ " love" ,
3+ " instagood" ,
4+ " photooftheday" ,
5+ " fashion" ,
6+ " beautiful" ,
7+ " happy" ,
8+ " cute" ,
9+ " tbt" ,
10+ " like4like" ,
11+ " followme" ,
12+ " picoftheday" ,
13+ " follow" ,
14+ " me" ,
15+ " selfie" ,
16+ " summer" ,
17+ " art" ,
18+ " instadaily" ,
19+ " friends" ,
20+ " repost" ,
21+ " nature" ,
22+ " girl" ,
23+ " fun" ,
24+ " style" ,
25+ " smile" ,
26+ " food" ,
27+ " music" ,
28+ " games" ,
29+ " playing" ,
30+ " sex" ,
31+ " friends" ,
32+ " food" ,
33+ " travel"
34+ ]
You can’t perform that action at this time.
0 commit comments