<commit_before># app/controllers/admin_censor_rule_controller.rb:
# For modifying requests.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/
#
# $Id: admin_censor_rule_controller.rb,v 1.1 2008-10-27 18:18:30 francis Exp $

class AdminCensorRuleController < ApplicationController
    layout "admin"
    before_filter :assign_http_auth_user

    def new
        @info_request = InfoRequest.find(params[:info_request_id])
    end

    def create
        params[:censor_rule][:last_edit_editor] = admin_http_auth_user()
        @censor_rule = CensorRule.new(params[:censor_rule])
        if @censor_rule.save
            expire_for_request(@censor_rule.info_request)
            flash[:notice] = 'CensorRule was successfully created.'
            redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s)
        else
            render :action => 'new'
        end
    end

    def edit
        @censor_rule = CensorRule.find(params[:id])
    end

    def update
        params[:censor_rule][:last_edit_editor] = admin_http_auth_user()
        @censor_rule = CensorRule.find(params[:id])
        if @censor_rule.update_attributes(params[:censor_rule])
            expire_for_request(@censor_rule.info_request)
            flash[:notice] = 'CensorRule was successfully updated.'
            redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s)
        else
            render :action => 'edit'
        end
    end
    
    def destroy
        censor_rule = CensorRule.find(params[:censor_rule_id])
        info_request = censor_rule.info_request

        censor_rule.destroy
        expire_for_request(info_request)

        flash[:notice] = "CensorRule was successfully destroyed."

        redirect_to admin_url('request/show/' + info_request.id.to_s)
    end

 
    def expire_for_request(info_request)
        # clear out cached entries<commit_msg>Make sure censor copes with filename rename<commit_after># app/controllers/admin_censor_rule_controller.rb:
# For modifying requests.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/
#
# $Id: admin_censor_rule_controller.rb,v 1.2 2008-10-28 13:03:52 francis Exp $

class AdminCensorRuleController < ApplicationController
    layout "admin"
    before_filter :assign_http_auth_user

    def new
        @info_request = InfoRequest.find(params[:info_request_id])
    end

    def create
        params[:censor_rule][:last_edit_editor] = admin_http_auth_user()
        @censor_rule = CensorRule.new(params[:censor_rule])
        expire_for_request(@censor_rule.info_request)
        if @censor_rule.save
            expire_for_request(@censor_rule.info_request)
            flash[:notice] = 'CensorRule was successfully created.'
            redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s)
        else
            render :action => 'new'
        end
    end

    def edit
        @censor_rule = CensorRule.find(params[:id])
    end

    def update
        params[:censor_rule][:last_edit_editor] = admin_http_auth_user()
        @censor_rule = CensorRule.find(params[:id])
        # expire before and after change, in case filename changes
        expire_for_request(@censor_rule.info_request)
        if @censor_rule.update_attributes(params[:censor_rule])
            expire_for_request(@censor_rule.info_request)
            flash[:notice] = 'CensorRule was successfully updated.'
            redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s)
        else
            render :action => 'edit'
        end
    end
    
    def destroy
        censor_rule = CensorRule.find(params[:censor_rule_id])
        info_request = censor_rule.info_request

        # expire before and after change, in case filename changes
        expire_for_request(info_request)
        censor_rule.destroy
        expire_for_request(info_request)

        flash[:notice] = "CensorRule was successfully destroyed."

        redirect_to admin_url('request/show/' + info_request.id.to_s)
    end

 
    def expire_for_request(info_request)
        # So is using latest censor rules
        info_request.reload

        # clear out cached entries
{'fraction_non_alphanumeric': 0.09103576405016256, 'fraction_numerical': 0.009289363678588018, 'mean_word_length': 2.958639705882353, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '521018', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1302, 'n_words': 257}