def get(id=None): """ Get a user given an ID. Get a list of users. """ current_app.logger.info('Entering users.views.get()...') if id is None: if current_user.role_id == ADMIN or current_user.role_id == STAFF: # Get and return list of users. users = User.query.all() return jsonify(dict(users=[user.as_dict() for user in users])) else: # Get and return current user. response = jsonify(status='success', data=current_user.as_dict()) response.status_code = 200 current_app.logger.debug('Returning success; response.data=[%s]' % response.data) return response else: # Get the user. user = User.query.get(id) # Return the user. if not user: response = jsonify(status='fail', data={'id': 'Sorry, no user found.'}) response.status_code = 200 current_app.logger.debug('Returning fail; data = [Sorry, no user found.].') return response else: response = jsonify(status='success', data=user.as_dict()) response.status_code = 200 current_app.logger.debug('Returning success; response.data=[%s]' % response.data) return response
def profile_photo(): try: current_app.user_profile_image_store.saveProfileImage( current_user, request.form.get('photo')) return jsonify(current_user.as_dict()) except Exception, e: current_app.logger.error("Error saving profile image: %s" % e) abort(400)
def get_current_user(): response = current_user.as_dict() return jsonify(response)
def me(cls): return jsonify(current_user.as_dict())