def create_default_users():
     UserDB.remove_all_users()
     users = [
         User({
             "username": "******",
             "password": "******",
             "email": "*****@*****.**",
             "mobile": "12345678900",
             "sex": "male",
             "permission": "admin"
         })
     ]
     for u in users:
         UserDB.add_user(u)
         logging.info("add user %s success..." % u.username)
示例#2
0
 def get_user_list():
     user_list = UserDB.get_user_list()
     user_list_copy = []
     for user in user_list:
         user_list_copy.append({
             "_id": str(user.get('_id')),
             "username": user.get('username'),
             "permission": user.get('permission')
         })
     return user_list_copy
示例#3
0
 def get_user_detail(user_id):
     user = UserDB.get_user_by_id(user_id)
     user_copy = {}
     user_copy.update({
         "_id": str(user.get('_id')),
         "username": user.get('username'),
         "email": user.get('email'),
         "mobile": user.get('mobile'),
         "sex": user.get("sex"),
         "permission": user.get("permission"),
         "create_time": user.get("create_time")
     })
     return user_copy
示例#4
0
 def update_user(user_id, user):
     UserDB.update_user(user_id, user)
示例#5
0
 def add_user(user):
     return UserDB.add_user(user)
示例#6
0
 def remove_user(user_id):
     UserDB.remove_user_by_id(user_id)
示例#7
0
 def login(user):
     UserDB.check_login(user)
     pass
示例#8
0
 def check_is_need_init():
     if UserDB.get_admin_user():
         return False
     else:
         return True