def delete(request):
    """plate delete """
    id = request.matchdict['id']
    dbsession = DBSession()
    plate = dbsession.query(Plate).filter_by(id=id).first()
    if plate is None:
        request.session.flash("error;Patente no encontrada!")
        return HTTPFound(location=request.route_url("plate_list"))        
    
    try:
        transaction.begin()
        dbsession.delete(plate);
        transaction.commit()
        request.session.flash("warning;Se elimino la patente!")
    except IntegrityError:
        # delete error
        transaction.abort()
        request.session.flash("error;La patente no se pudo eliminar!")
    
    return HTTPFound(location=request.route_url("plate_list"))
def delete(request):
    """device delete """
    id = request.matchdict['id']
    dbsession = DBSession()
    device = dbsession.query(Device).filter_by(id=id).first()
    if device is None:
        request.session.flash("error;No se encontro el dispositivo!")
        return HTTPFound(location=request.route_url("device_list"))        
    
    try:
        transaction.begin()
        dbsession.delete(device);
        transaction.commit()
        request.session.flash("warning;Se elimino el dispositivo!")
    except IntegrityError:
        # delete error
        transaction.abort()
        request.session.flash("error;No se pudo eliminar el dispositivo!")
    
    return HTTPFound(location=request.route_url("device_list"))
def delete(request):
    """brand delete """
    id = request.matchdict["id"]
    dbsession = DBSession()
    brand = dbsession.query(Brand).filter_by(id=id).first()
    if brand is None:
        request.session.flash("error;Marca inexistente!")
        return HTTPFound(location=request.route_url("brand_list"))

    try:
        transaction.begin()
        dbsession.delete(brand)
        transaction.commit()
        request.session.flash("warning;Marca inexistente!")
    except IntegrityError:
        # delete error
        transaction.abort()
        request.session.flash(
            "error;No se pudo eliminar la marca. Verifique que no este siendo usada por ningun registro!"
        )

    return HTTPFound(location=request.route_url("brand_list"))