def add_super_user(name, nickname, password, is_super=True): admin = User( name=name, nickname=nickname, avatar_url="/static/pic/monkey-32-32px.png", is_super=is_super) admin.set_password(password) User.objects(name=name).update_one(__raw__={"$set": admin.to_mongo().to_dict()}, upsert=True) return admin
def setup_db(): """Initialize db tables make sure database and user correctly created in db in case upgrade the table structure, the origin table need be dropped firstly """ # init REQUIRED db data. # reserved user is deleted, may not need in mongodb implementation # default super admin admin = User( name="admin", nickname="admin", password="******", is_super=True) User.objects(name="admin").update_one(__raw__={"$set": admin.to_mongo().to_dict()}, upsert=True)
def setup_db(): """Initialize db tables make sure database and user correctly created in db in case upgrade the table structure, the origin table need be dropped firstly """ # init REQUIRED db data. # reserved user is deleted, may not need in mongodb implementation # default super admin admin = User(name="admin", nickname="admin", password="******", avatar_url="/static/pic/monkey-32-32px.png", is_super=True) User.objects(name="admin").update_one( __raw__={"$set": admin.to_mongo().to_dict()}, upsert=True)