<commit_before>class Admin::ImagesController < Admin::BaseController

  include Admin::ImagesHelper

  crudify :image,
          :order => "created_at DESC",
          :sortable => false

  before_filter :change_list_mode_if_specified, :init_dialog

  def index
    if searching?
      search_and_paginate_all_images
    else
      paginate_all_images
    end

    if RefinerySetting.find_or_set(:group_images_by_date_uploaded, true)
      @grouped_images = group_by_date(@images)
    end
  end

  def new
    @image = Image.new if @image.nil?

    @url_override = admin_images_url(:dialog => from_dialog?)
  end

  def insert
    self.new if @image.nil?

    @url_override = admin_images_url(:dialog => from_dialog?, :insert => true)

    if params[:conditions].present?
      extra_condition = params[:conditions].split(',')

      extra_condition[1] = true if extra_condition[1] == "true"
      extra_condition[1] = false if extra_condition[1] == "false"
      extra_condition[1] = nil if extra_condition[1] == "nil"
      paginate_images({extra_condition[0].to_sym => extra_condition[1]})
    else
      paginate_images
    end

    render :action => "insert"
  end

  def create    
    begin    
      @image = Image.create(params[:image]) 
    rescue Dragonfly::Delegator::UnableToHandle
      @image = Image.new      
    end  

    unless params[:insert]
      if @image.valid?
        flash[:notice] = t('refinery.crudify.created', :what => "'#{@image.title}'")
        unless from_dialog?
          redirect_to :action => 'index'
        else
          render :text => "<script type='text/javascript'>parent.window.location = '#{admin_images_url}';</script>"
        end
      else
        self.new # important for dialogs
        render :action => 'new'
      end
    else
      if @image.valid?
        @image_id = @image.id
        @image = nil        
      end
      self.insert
    end
  end

protected

  def init_dialog
    @app_dialog = params[:app_dialog].present?
    @field = params[:field]
    @update_image = params[:update_image]<commit_msg>Removed whitespace I accidently added<commit_after>class Admin::ImagesController < Admin::BaseController

  include Admin::ImagesHelper

  crudify :image,
          :order => "created_at DESC",
          :sortable => false

  before_filter :change_list_mode_if_specified, :init_dialog

  def index
    if searching?
      search_and_paginate_all_images
    else
      paginate_all_images
    end

    if RefinerySetting.find_or_set(:group_images_by_date_uploaded, true)
      @grouped_images = group_by_date(@images)
    end
  end

  def new
    @image = Image.new if @image.nil?

    @url_override = admin_images_url(:dialog => from_dialog?)
  end

  def insert
    self.new if @image.nil?

    @url_override = admin_images_url(:dialog => from_dialog?, :insert => true)

    if params[:conditions].present?
      extra_condition = params[:conditions].split(',')

      extra_condition[1] = true if extra_condition[1] == "true"
      extra_condition[1] = false if extra_condition[1] == "false"
      extra_condition[1] = nil if extra_condition[1] == "nil"
      paginate_images({extra_condition[0].to_sym => extra_condition[1]})
    else
      paginate_images
    end

    render :action => "insert"
  end

  def create    
    begin    
      @image = Image.create(params[:image]) 
    rescue Dragonfly::Delegator::UnableToHandle
      @image = Image.new      
    end  

    unless params[:insert]
      if @image.valid?
        flash[:notice] = t('refinery.crudify.created', :what => "'#{@image.title}'")
        unless from_dialog?
          redirect_to :action => 'index'
        else
          render :text => "<script type='text/javascript'>parent.window.location = '#{admin_images_url}';</script>"
        end
      else
        self.new # important for dialogs
        render :action => 'new'
      end
    else
      if @image.valid?
        @image_id = @image.id
        @image = nil
      end
      self.insert
    end
  end

protected

  def init_dialog
    @app_dialog = params[:app_dialog].present?
    @field = params[:field]
    @update_image = params[:update_image]
{'fraction_non_alphanumeric': 0.1108433734939759, 'fraction_numerical': 0.0038554216867469878, 'mean_word_length': 2.7770700636942673, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, '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': '7314026', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1269, 'n_words': 277}