<commit_before>class GitolitePublicKeysController < ApplicationController
  unloadable
  
  before_filter :require_login
  before_filter :set_user_variable
  before_filter :find_gitolite_public_key, :except => [:index, :new, :create]

  def index
    @status = if (session[:gitolite_public_key_filter_status]=params[:status]).nil?
      GitolitePublicKey::STATUS_ACTIVE
    elsif params[:status].blank?
        nil
    else 
      params[:status].to_i != 0
    end
    c = ARCondition.new(@status ? ["active=?", @status] : nil)

    @gitolite_public_keys = @user.gitolite_public_keys.all(:order => 'active DESC, created_at DESC', :conditions => c.conditions)
    respond_to do |format|
      format.html # index.html.erb
      format.json  { render :json => @gitolite_public_keys }
    end
  end
  
  def edit
  end

  def update
    if @gitolite_public_key.update_attributes(params[:public_key])
      flash[:notice] = l(:notice_public_key_updated)
      redirect_to url_for(:action => 'index', :status => session[:gitolite_public_key_filter_status])
    else
      render :action => 'edit'
    end
  end
  
  def new
    @gitolite_public_key = GitolitePublicKey.new(:user => @user)
  end
  
  def create
    @gitolite_public_key = GitolitePublicKey.new(params[:public_key].merge(:user => @user))
    if @gitolite_public_key.save
      flash[:notice] = l(:notice_public_key_added)
      redirect_to url_for(:action => 'index', :status => session[:gitolite_public_key_filter_status])
    else
      render :action => 'new'
    end<commit_msg>unlock on key from index works<commit_after>class GitolitePublicKeysController < ApplicationController
  unloadable
  
  before_filter :require_login
  before_filter :set_user_variable
  before_filter :find_gitolite_public_key, :except => [:index, :new, :create]

  def index
    @status = if (session[:gitolite_public_key_filter_status]=params[:status]).nil?
      GitolitePublicKey::STATUS_ACTIVE
    elsif params[:status].blank?
        nil
    else 
      params[:status].to_i != 0
    end
    c = ARCondition.new(@status ? ["active=?", @status] : nil)

    @gitolite_public_keys = @user.gitolite_public_keys.all(:order => 'active DESC, created_at DESC', :conditions => c.conditions)
    respond_to do |format|
      format.html # index.html.erb
      format.json  { render :json => @gitolite_public_keys }
    end
  end
  
  def edit
  end

  def update
    if params[:public_key][:active]
      status = params[:public_key].delete :active
      if status == "true"
        @gitolite_public_key.active = true
      elsif status == "false"
        @gitolite_public_key.active = false
      end
    end

    if @gitolite_public_key.update_attributes(params[:public_key])
      flash[:notice] = l(:notice_public_key_updated)
      redirect_to url_for(:action => 'index', :status => session[:gitolite_public_key_filter_status])
    else
      render :action => 'edit'
    end
  end
  
  def new
    @gitolite_public_key = GitolitePublicKey.new(:user => @user)
  end
  
  def create
    @gitolite_public_key = GitolitePublicKey.new(params[:public_key].merge(:user => @user))
    if @gitolite_public_key.save
      flash[:notice] = l(:notice_public_key_added)
      redirect_to url_for(:action => 'index', :status => session[:gitolite_public_key_filter_status])
    else
      render :action => 'new'
    end
{'fraction_non_alphanumeric': 0.11227232009555091, 'fraction_numerical': 0.0005971931919976113, 'mean_word_length': 3.758522727272727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '248667', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1071, 'n_words': 213}