def put(self, username): data = User.parser.parse_args() user = UserModel.find_by_username(username) if user is None: user = UserModel(username, **data) else: user.username = username user.user_type = data['user_type'] user.first_name = data['first_name'] user.last_name = data['last_name'] user.assigned_mentor = data['assigned_mentor'] user.save_to_db() return user.json()