Esempio n. 1
0
def delete_thread(thread_uid):
    """Delete given thread and all its comments.

    :param thread_uid: Thread unique ID.
    """
    thread = storage.get_thread(thread_uid)
    if not thread:
        abort(404)

    if thread['author'] != g.username:
        abort(403)

    if request.method == 'GET':
        return render_template('delete_thread.html',
                               thread=thread,
                               thread_uid=thread_uid)

    if request.form.get('confirm') != 'confirm':
        return error('delete_thread:confirm')

    storage.delete_thread(thread_uid)
    flash('Thread Succesfully Deleted: {0}'.format(thread['subject']),
          'success')

    return to_threads()
Esempio n. 2
0
def main():
    """Wipe all data from Links and Content storages."""
    start_time = time.time()
    print('Start deleting available Threads')

    with app.app_context():
        # Storage requires app in global context
        import storage

        for thread_uid, thread in iteritems(storage.list_threads()):
            storage.delete_thread(thread_uid)
            print('    Thread deleted! UID #{0}, subject: {1}'.
                  format(thread_uid, thread['subject']))

        storage.links.delete(build_key(THREADS_KEY))

    print('All Threads deleted. Done in {0:.4f}s'.
          format(time.time() - start_time))
    return False