Ejemplo n.º 1
0
def bulk_delete(sid, docs_selected):
    confirm_delete = bool(request.form.get('confirm_delete', False))
    if confirm_delete:
        for doc in docs_selected:
            fn = store.path(sid, doc['name'])
            store.secure_unlink(fn)
    return render_template(
        'delete.html', sid=sid, codename=db.display_id(sid, db.sqlalchemy_handle()),
        docs_selected=docs_selected, confirm_delete=confirm_delete)
Ejemplo n.º 2
0
def delete():
    query = Reply.query.filter(Reply.filename == request.form['reply_filename'])
    reply = get_one_or_else(query, app.logger, abort)
    store.secure_unlink(store.path(g.sid, reply.filename))
    db_session.delete(reply)
    db_session.commit()

    flash("Reply deleted", "notification")
    return redirect(url_for('lookup'))
Ejemplo n.º 3
0
def delete():
    msgid = request.form['msgid']
    assert '/' not in msgid
    potential_files = os.listdir(g.loc)
    if msgid not in potential_files:
        abort(404)  # TODO are the checks necessary?
    store.secure_unlink(store.path(g.sid, msgid))
    flash("Reply deleted.", "notification")

    return redirect(url_for('lookup'))
Ejemplo n.º 4
0
def delete():
    msgid = request.form['msgid']
    assert '/' not in msgid
    potential_files = os.listdir(g.loc)
    if msgid not in potential_files:
        abort(404)  # TODO are the checks necessary?
    store.secure_unlink(store.path(g.sid, msgid))
    flash("Reply deleted.", "notification")

    return redirect(url_for('lookup'))
Ejemplo n.º 5
0
def bulk_delete(sid, docs_selected):
    source = get_source(sid)
    confirm_delete = bool(request.form.get('confirm_delete', False))
    if confirm_delete:
        for doc in docs_selected:
            fn = store.path(sid, doc['name'])
            store.secure_unlink(fn)
    return render_template('delete.html', sid=sid,
            codename=source.journalist_designation,
            docs_selected=docs_selected, confirm_delete=confirm_delete)
Ejemplo n.º 6
0
def bulk_delete(sid, docs_selected):
    confirm_delete = bool(request.form.get('confirm_delete', False))
    if confirm_delete:
        for doc in docs_selected:
            fn = store.path(sid, doc['name'])
            store.secure_unlink(fn)
    return render_template('delete.html',
                           sid=sid,
                           codename=db.display_id(sid, db.sqlalchemy_handle()),
                           docs_selected=docs_selected,
                           confirm_delete=confirm_delete)
Ejemplo n.º 7
0
def batch_delete():
    replies = g.source.replies
    if len(replies) == 0:
        app.logger.error("Found no replies when at least one was expected")
        return redirect(url_for('lookup'))
    for reply in replies:
        store.secure_unlink(store.path(g.filesystem_id, reply.filename))
        db_session.delete(reply)
    db_session.commit()

    flash("All replies have been deleted", "notification")
    return redirect(url_for('lookup'))
Ejemplo n.º 8
0
 def test_secure_unlink(self, mock_check_call):
     path = os.path.join(config.STORE_DIR, 'FILENAME')
     self.assertEqual(store.secure_unlink(path), "success")
     mock_check_call.assert_called_with(['srm', path])