def _normalize_locations(context, image, force_show_deleted=False):
 if ((image['status'] == 'deactivated') and (not context.is_admin)):
  image['locations'] = []
  return image
 if force_show_deleted:
  locations = image['locations']
 else:
  locations = [x for x in image['locations'] if (not x.deleted)]
 image['locations'] = [{'id': loc['id'], 'url': loc['value'], 'metadata': loc['meta_data'], 'status': loc['status']} for loc in locations]
 return image

def _normalize_locations ( context , image , force_show_deleted = False ) : if ( ( image [ 'status' ] == 'deactivated' ) and ( not context . is_admin ) ) : image [ 'locations' ] = [ ] return image if force_show_deleted : locations = image [ 'locations' ] else : locations = [ x for x in image [ 'locations' ] if ( not x . deleted ) ] image [ 'locations' ] = [ { 'id' : loc [ 'id' ] , 'url' : loc [ 'value' ] , 'metadata' : loc [ 'meta_data' ] , 'status' : loc [ 'status' ] } for loc in locations ] return image
generate suitable dictionary list for locations field of image .