Пример #1
0
def images_tags():
    if request.method == 'POST':
        img_ids = request.form.getlist('imageIds[]')
        tag_ids = request.form.getlist('tagIds[]')

        Image.add_tags(session, img_ids, tag_ids)

        return jsonify(AjaxResult(True, 'Tags attached to images successfully').to_json())
Пример #2
0
def images_people():
    if request.method == 'POST':
        img_id = request.args.get('imageId')
        p_id = request.args.get('personId')
        action = request.args.get('action')

        if action == 'add':
            result = Image.add_person(session, img_id, p_id)
            return jsonify(AjaxResult(True, 'Person added to image successfully', result.to_json()).to_json())
        else:
            result = Image.remove_person(session, img_id, p_id)
            return AjaxResult(True, 'Person removed from image successfully', result.to_json()).to_json()
Пример #3
0
def image():
    if request.method == 'GET':
        img = Image.get_image(session, request.args.get('imageId'))
        return jsonify(AjaxResult(True, 'Image retrieved successfully', img.to_json()).to_json())

    if request.method == 'POST':
        file = request.files['img']
        t = request.form.getlist('tags')
        p = request.form.getlist('people')

        img = Image.create_image(session, scarlett.storage, file, t, p)

        return jsonify(AjaxResult(True, 'Image uploaded successfully!', img).to_json())
Пример #4
0
def image_tags():
    if request.method == 'POST':
        img_id = request.args.get('imageId')
        t_id = request.args.get('tagId')
        action = request.args.get('action')

        if action == 'add':
            result = Image.add_tags(session, [img_id], [t_id])
        else:
            result = Image.remove_tag(session, img_id, t_id)

        if result:
            return jsonify(AjaxResult(True, 'Tags added to images successfully').to_json())
        else:
            return jsonify(AjaxResult(False, 'An error occurred').to_json())
Пример #5
0
def upload_remote_image():
    url = request.form.get('url')
    t = request.form.getlist('tags')
    p = request.form.getlist('people')

    img = Image.create_image_from_url(scarlett.storage, session, url, t, p)
    return jsonify(AjaxResult(True, 'Image uploaded successfully!', img).to_json())
Пример #6
0
def images():
    if request.method == 'GET':
        return 'Huh'

    if request.method == 'POST':
        local_dir = request.form['dir']
        t = request.form.getlist('tags')
        p = request.form.getlist('people')

        result = Image.create_images(scarlett.storage, session, local_dir, t, p)

        return jsonify(AjaxResult(True, 'Images uploaded successfully', result).to_json())
Пример #7
0
def open_images():
    Image.open_images(session, request.form.getlist('images[]'))

    return jsonify(AjaxResult(True, 'Opening images...').to_json())
Пример #8
0
def open_image(image_id):
    i = Image.get_image(session, image_id)
    Image.open_images(session, [i.Image_Name])
    # TODO update client-side message
    return jsonify(AjaxResult(True, 'Opening image...').to_json())