Ejemplo n.º 1
0
def deleteItemView(list_id, item_id):
    ''' View for deleting an item
    '''
    # just check permissions on the item
    get_item_with_permission(list_id, item_id, session['user_id'])
    Item.delete(id=item_id)
    return jsonify({})
Ejemplo n.º 2
0
def checkItemView(list_id, item_id):
    ''' View for deleting an item
    '''
    status = None
    message = None
    item, list_owner = get_item_with_permission(
        list_id,
        item_id,
        session['user_id']
    )
    if list_owner:
        return flask.abort(403)
    if item.status == 1:
        new_status = 0
        checked_by = None
    else:
        new_status = 1
        checked_by = session['user_id']
    try:
        Item.update(
            {'status': new_status, 'checked_by': checked_by},
            id=item.id
        )
        status = 'ok'
    except Exception:
        status = 'error'
        message = 'could not update item'

    return jsonify(
        {
            'status': status,
            'message': message,
            'update_status': new_status,
        }
    )
Ejemplo n.º 3
0
def editItemView(list_id, item_id):
    ''' View for editing an item
    '''
    error_message = None
    update_status = None
    item, list_owner = get_item_with_permission(
        list_id,
        item_id,
        session['user_id']
    )
    if not list_owner:
        return flask.abort(403)
    if request.method == 'POST':
        try:
            Item.update(request.form, id=item_id)
            update_status = True
            render_item = Item.fetch_one(
                id=item.id
            )
        except Exception, e:
            update_status = False
            error_message = str(e)
            render_item = dict_to_obj(request.form.to_dict())