Skip to content
Snippets Groups Projects
Commit cd9baea9 authored by fibasile's avatar fibasile
Browse files

update seed scripts

parent 92835527
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ for key in projects_list.keys():
'tags': p.get('tags',{}).values() ,
'photos': p.get('photos',{}).values(),
'files': p.get('files',{}).values(),
'comments': p.get('comments',{}).values()
'comments': p.get('comments',{}).values(),
}
users[p['userId']]={ 'name' : p.get('username',''), 'uid': p['userId'], 'avatarURL': p['userAvatar'] }
projects.append(project)
......
......@@ -46,7 +46,10 @@ def import_projects():
'userId': p['userId'],
'downloadsCount': p.get('downloadsCount', 0),
'commentsCount': p.get('commentsCount',0) ,
'tags': p.get('tags', [])
'tags': p.get('tags', []),
"featured": False,
'status': u'published',
'owner': db.collection(u'profile').document(p['userId'])
}
ref = db.collection(u'projects').document(p['id'])
......@@ -62,6 +65,8 @@ def import_categories():
ref.set({"label": c['label'], "id": c['id']})
def import_files():
for p in projects:
......@@ -87,8 +92,11 @@ def import_comments():
for p in projects:
ref = db.collection(u'projects').document(p['id'])
files = p.get('comments', [])
delete_collection(ref.collection(u'comments'), 100)
for f in files:
file_ref = ref.collection(u'comments').document()
f['status'] = 'published'
f['author'] = db.collection(u'profile').document(p['userId'])
file_ref.set(f)
print(f)
......@@ -104,12 +112,22 @@ def import_users():
data[u'web']=u""
data[u'location']=u''
ref.set(data)
ref = db.collection(u'collections').document()
c_data = {
"name": u"Default collection",
"uid": user,
"description": u"",
"category": u"default",
"status": u"private",
"featured": False
}
ref.set(c_data)
print(data)
if __name__=='__main__':
#import_projects()
import_projects()
#import_files()
# import_comments()
#import_comments()
# import_photos()
# import_categories()
import_users()
\ No newline at end of file
# import_users()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment