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}
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}
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}
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'}
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'}
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' }
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}
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' }
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}