(image_id)
Edit a single image.
Edit a single image.
Edit a single image .
def edit_image(image_id):
  """ Edit a single image.
  """

  image = mongo.db.image.find_one_or_404({'id' : image_id})
  annotations = list(mongo.db.annotation.find({'image_id' : image_id}))
  categories = list(mongo.db.category.find())

  image = json_util.dumps(image)
  annotations = json_util.dumps(annotations)
  categories = json_util.dumps(categories)

  if request.is_xhr:
    # Return just the data
    return jsonify({
      'image' : json.loads(image),
      'annotations' : json.loads(annotations),
      'categories' : json.loads(categories)
    })
  else:
    # Render a webpage to edit the annotations for this image
    return render_template('edit_image.html', image=image, annotations=annotations, categories=categories)
def edit_image ( image_id ) : image = mongo . db . image . find_one_or_404 ( { 'id' : image_id } ) annotations = list ( mongo . db . annotation . find ( { 'image_id' : image_id } ) ) categories = list ( mongo . db . category . find ( ) ) image = json_util . dumps ( image ) annotations = json_util . dumps ( annotations ) categories = json_util . dumps ( categories ) if request . is_xhr : # Return just the data return jsonify ( { 'image' : json . loads ( image ) , 'annotations' : json . loads ( annotations ) , 'categories' : json . loads ( categories ) } ) else : # Render a webpage to edit the annotations for this image return render_template ( 'edit_image.html' , image = image , annotations = annotations , categories = categories )