Exemple #1
0
def instrumentos_borrar():
    resp = checkAccess("ELIMINAR_INSTRUMENTO")
    if not resp == 'true':
        return resp

    # Borrar img
    Instrumento.db = get_db()
    instrumento = Instrumento.find_by_id(request.form['hiddenAluId'])
    if instrumento['imagen'] != "no_image.jpeg" and instrumento['imagen'] != "":
        # pathUrl="flaskps"+url_for('static', filename='uploads/')
        urlImg = path.join(pathUrl, instrumento['imagen'])
        if path.isfile(urlImg):
            remove(urlImg)

    try:
        # Instrumento.db = get_db()
        Instrumento.db.autocommit = False
        Instrumento.delete(request.form['hiddenAluId'])
        Instrumento.db.commit()

        flash("Se eliminó con éxito", "success")
        return redirect(url_for('instrumentos_lista'))

    except Exception as e:
        flash(str(e), "danger")
        Instrumento.db.rollback()
        return redirect(url_for('instrumentos_lista'))
Exemple #2
0
def delete():
    Instrumento.db = get_db()
    id_instrumento= request.args.get('id')
    Instrumento.delete(id_instrumento)
    instrumentos = Instrumento.all()
    return render_template('instrumentos/index.html', instrumentos=instrumentos)