<commit_before>ActiveAdmin.register AdminUser do
  
  filter :email
  
  index do            
    selectable_column if AdminUser.true_admin? current_admin_user.id 
    column :email
    column :owner do |a|
      AdminUser.true_admin? a.id
    end
    column :current_sign_in_at        
    column :last_sign_in_at           
    column :sign_in_count   
    actions if AdminUser.true_admin? current_admin_user.id 
  end


  form do |f|                         
    f.inputs "Admin Details" do       
      f.input :email                  
      f.input :password               
      f.input :password_confirmation  
    end                               
    f.actions                         
  end        
  
  controller do
    def destroy
      if AdminUser.true_admin? current_admin_user.id 
        super
      else
        flash[:alert] = "Warning: You don't have enough privilege to delete"
        redirect_to "admin/admin_users/"
      end
    end
    
    def new
      if AdminUser.true_admin? current_admin_user.id 
        super
      else
        flash[:alert] = "Warning: You don't have enough privilege to create another admin"
        redirect_to "/admin/admin_users/"
      end
    end<commit_msg>impr:  restrict the delete behavior<commit_after>ActiveAdmin.register AdminUser do
  
  filter :email
  
  index do            
    selectable_column if AdminUser.true_admin? current_admin_user.id 
    column :email
    column :owner do |a|
      AdminUser.true_admin? a.id
    end
    column :current_sign_in_at        
    column :last_sign_in_at           
    column :sign_in_count   
    actions if AdminUser.true_admin? current_admin_user.id 
  end


  form do |f|                         
    f.inputs "Admin Details" do       
      f.input :email                  
      f.input :password               
      f.input :password_confirmation  
    end                               
    f.actions                         
  end        
  
  controller do
    def destroy
      if AdminUser.true_admin? current_admin_user.id 
        if current_admin_user.id.to_s == params[:id].to_s
          flash[:alert] = "Warning: Site owner can not be deleted"
          redirect_to "/admin/admin_users/"
        else
          super
        end
      else
        flash[:alert] = "Warning: You don't have enough privilege to delete"
        redirect_to "/admin/admin_users/"
      end
    end
    
    def new
      if AdminUser.true_admin? current_admin_user.id 
        super
      else
        flash[:alert] = "Warning: You don't have enough privilege to create another admin"
        redirect_to "/admin/admin_users/"
      end
    end
{'fraction_non_alphanumeric': 0.05649717514124294, 'fraction_numerical': 0.0, 'mean_word_length': 1.573643410852713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '885195', 'n_tokens_mistral': 757, 'n_tokens_neox': 731, 'n_words': 200}