예제 #1
0
파일: cards.py 프로젝트: nextgis/nextgisbio
def delete_card(request):
    card_id = request.matchdict['id']
    success = True
    try:
        with transaction.manager:
            dbsession = DBSession()
            card = dbsession.query(Cards).filter_by(id=card_id).one()
            dbsession.delete(card)
    except:
        success = False
    return {'success': success}
예제 #2
0
def delete_anlist(request):
    annotation_id = request.matchdict['id']
    success = True
    try:
        with transaction.manager:
            dbsession = DBSession()
            annotation = dbsession.query(Annotation).filter_by(id=annotation_id).one()
            dbsession.delete(annotation)
    except:
        success = False
    return {'success': success}
예제 #3
0
def delete_anlist(request):
    annotation_id = request.matchdict['id']
    success = True
    try:
        with transaction.manager:
            dbsession = DBSession()
            annotation = dbsession.query(Annotation).filter_by(id=annotation_id).one()
            dbsession.delete(annotation)
    except:
        success = False
    return {'success': success}
예제 #4
0
def table_delete_jtable(request):
    session = DBSession()
    table, table_name = helpers.get_table_by_name(request)

    if ('id' in request.POST) and request.POST['id'].isdigit():
        item_id = int(request.POST['id'])
        item = session.query(table).get(item_id)
    else:
        raise Exception('Deleting item: id is not applied')

    session.delete(item)
    transaction.commit()
    session.close()

    return {'Result': 'OK'}
예제 #5
0
def table_delete_jtable(request):
    session = DBSession()

    if ('person_id' in request.POST) and request.POST['person_id'].isdigit():
        person_id = int(request.POST['person_id'])
        person = session.query(Person).options(
            joinedload('user')).get(person_id)
    else:
        raise Exception('Deleting item: id is not applied')

    session.delete(person)
    session.delete(person.user)
    transaction.commit()
    session.close()

    return {'Result': 'OK'}
예제 #6
0
def table_delete_jtable(request):
    session = DBSession()

    if ('person_id' in request.POST) and request.POST['person_id'].isdigit():
        person_id = int(request.POST['person_id'])
        person = session.query(Person).options(joinedload('user')).get(person_id)
    else:
        raise Exception('Deleting item: id is not applied')

    session.delete(person)
    session.delete(person.user)
    transaction.commit()
    session.close()

    return {
        'Result': 'OK'
    }
예제 #7
0
def remove_image(request):
    image_id = request.matchdict['image_id']
    obj_type = request.matchdict['type']

    with transaction.manager:
        dbSession = DBSession()
        dbSession.query(CardsImages).filter_by(image_id=image_id).delete()
        image = dbSession.query(Images).filter_by(id=image_id).one()
        if image.local and os.path.exists(image.local):
            os.remove(image.local)
            path_without_ext, extension = os.path.splitext(image.local)[0], os.path.splitext(image.local)[1]
            for key_size in THUMBNAIL_SIZES:
                os.remove('%s_%s%s' % (path_without_ext, key_size, extension))

        dbSession.delete(image)

    return {'success': True}
예제 #8
0
def table_delete_jtable(request):
    session = DBSession()
    table, table_name = helpers.get_table_by_name(request)

    if ('id' in request.POST) and request.POST['id'].isdigit():
        item_id = int(request.POST['id'])
        item = session.query(table).get(item_id)
    else:
        raise Exception('Deleting item: id is not applied')

    session.delete(item)
    transaction.commit()
    session.close()

    return {
        'Result': 'OK'
    }
예제 #9
0
def remove_image(request):
    image_id = request.matchdict['image_id']
    obj_type = request.matchdict['type']

    with transaction.manager:
        dbSession = DBSession()
        dbSession.query(CardsImages).filter_by(image_id=image_id).delete()
        image = dbSession.query(Images).filter_by(id=image_id).one()
        if image.local and os.path.exists(image.local):
            os.remove(image.local)
            path_without_ext, extension = os.path.splitext(
                image.local)[0], os.path.splitext(image.local)[1]
            for key_size in THUMBNAIL_SIZES:
                os.remove('%s_%s%s' % (path_without_ext, key_size, extension))

        dbSession.delete(image)

    return {'success': True}