def delete():
    """Delete a post."""
    form = DeleteForm()
    path = request.form['path']
    post = find_post(path)
    if post is None:
        return error("No such post or page.", 404)
    if not form.validate():
        return error("Bad Request", 400)

    current_auid = int(post.meta('author.uid') or current_user.uid)

    if (not current_user.can_edit_all_posts and
            current_auid != current_user.uid):
        return error("Cannot edit posts of other users.", 401)

    os.unlink(path)
    if post.is_two_file:
        meta_path = os.path.splitext(path)[0] + '.meta'
        os.unlink(meta_path)
    scan_site()
    if db is not None:
        db.set('site:needs_rebuild', '1')
    else:
        site.coil_needs_rebuild = '1'
    return redirect(url_for('index'))
def delete ( ) : form = DeleteForm ( ) path = request . form [ 'path' ] post = find_post ( path ) if post is None : return error ( "No such post or page." , 404 ) if not form . validate ( ) : return error ( "Bad Request" , 400 ) current_auid = int ( post . meta ( 'author.uid' ) or current_user . uid ) if ( not current_user . can_edit_all_posts and current_auid != current_user . uid ) : return error ( "Cannot edit posts of other users." , 401 ) os . unlink ( path ) if post . is_two_file : meta_path = os . path . splitext ( path ) [ 0 ] + '.meta' os . unlink ( meta_path ) scan_site ( ) if db is not None : db . set ( 'site:needs_rebuild' , '1' ) else : site . coil_needs_rebuild = '1' return redirect ( url_for ( 'index' ) )
Delete a post.