<commit_before>class DomainsController < ApplicationController
  before_filter :admin_required
  before_filter :find_domain, except: [:index, :new, :create]

  def index
    @domains = Domain.order('name')
  end
  
  def show
  end

  def new
    @domain = Domain.new
    begin
      org = Organisation.find(params[:organisation_id])
      @domain.organisation_id = params[:organisation_id]
    rescue
      flash[:notice] = 'No organisation. Chaos!'
      redirect_to domains_path
    end
  end

  def create
    @domain = Domain.new(domain_params)
    if @domain.save
      flash[:notice] = "Added new domain."
      redirect_to domain_path(@domain)
    else
      @organisation = @domain.organisation
      render action: 'new'
    end
  end

  def edit
  end

  def update
    if @domain.update_attributes(domain_params)
      redirect_to @domain, notice: 'Domain updated.'
    else
      render action: 'edit'
    end
  end

  def destroy
    @domain.destroy
    redirect_to @domain.organisation, notice: 'Domain deleted.'
  end

  def renewals
    
  end

  private
  
  def find_domain
    @domain = Domain.find_by_id(params[:id], include: :organisation)
    if @domain.nil?
      redirect_to domains_path, notice: "That domain doesn't exist."
    end
  end

  def domain_params
    params.require(:domain).permit(:name, :forwarding_id, :organisation_id, :registered_on, :with_us)
  end
end<commit_msg>Fix ordering of domain params to match spec<commit_after>class DomainsController < ApplicationController
  before_filter :admin_required
  before_filter :find_domain, except: [:index, :new, :create]

  def index
    @domains = Domain.order('name')
  end
  
  def show
  end

  def new
    @domain = Domain.new
    begin
      org = Organisation.find(params[:organisation_id])
      @domain.organisation_id = params[:organisation_id]
    rescue
      flash[:notice] = 'No organisation. Chaos!'
      redirect_to domains_path
    end
  end

  def create
    @domain = Domain.new(domain_params)
    if @domain.save
      flash[:notice] = "Added new domain."
      redirect_to domain_path(@domain)
    else
      @organisation = @domain.organisation
      render action: 'new'
    end
  end

  def edit
  end

  def update
    if @domain.update_attributes(domain_params)
      redirect_to @domain, notice: 'Domain updated.'
    else
      render action: 'edit'
    end
  end

  def destroy
    @domain.destroy
    redirect_to @domain.organisation, notice: 'Domain deleted.'
  end

  def renewals
    
  end

  private
  
  def find_domain
    @domain = Domain.find_by_id(params[:id], include: :organisation)
    if @domain.nil?
      redirect_to domains_path, notice: "That domain doesn't exist."
    end
  end

  def domain_params
    params.require(:domain).permit(:forwarding_id, :name, :organisation_id, :registered_on, :with_us)
  end
end
{'fraction_non_alphanumeric': 0.0898876404494382, 'fraction_numerical': 0.0, 'mean_word_length': 3.07, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4537913', 'n_tokens_mistral': 910, 'n_tokens_neox': 875, 'n_words': 234}