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)
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
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
def update_user(user_id, user): UserDB.update_user(user_id, user)
def add_user(user): return UserDB.add_user(user)
def remove_user(user_id): UserDB.remove_user_by_id(user_id)
def login(user): UserDB.check_login(user) pass
def check_is_need_init(): if UserDB.get_admin_user(): return False else: return True