<commit_before>class Admin::SponsorsController < Admin::ApplicationController
  before_filter :set_sponsor, only: %i[show edit update]

  def index
    authorize Sponsor
    @sponsors = Sponsor.all.order(:name)
  end

  def new
    @sponsor = Sponsor.new
    @sponsor.build_address
    @sponsor.contacts.build
    authorize @sponsor
  end

  def create
    @sponsor = Sponsor.new(sponsor_params)
    @sponsor.build_address unless @sponsor.address.present?
    authorize @sponsor
    if @sponsor.save
      flash[:notice] = "Sponsor #{@sponsor.name} created"
      redirect_to [:admin, @sponsor]
    else
      flash[:notice] = @sponsor.errors.full_messages.to_s
      render 'new'
    end
  end

  def edit
    @sponsor = Sponsor.find(params[:id])
    authorize @sponsor
    @sponsor.build_address unless @sponsor.address.present?
    @sponsor.contacts.build
  end

  def update
    @sponsor.update_attributes(sponsor_params)
    redirect_to admin_sponsor_path(@sponsor), notice: 'Updated!'
  end

  private
  def sponsor_params
    params.require(:sponsor).permit(:name, :avatar, :website, :seats, :accessibility_info, :number_of_coaches, :level, :email, :contact_first_name, :contact_surname, contact_ids: [], address_attributes: %i[flat street postal_code city latitude longitude directions])
  end

  def set_sponsor
    @sponsor = Sponsor.find(params[:id])
    authorize @sponsor
  end
end<commit_msg>Fixes Line is too long rubocop offence in admin/sponsors_controller raised by codeclimate<commit_after>class Admin::SponsorsController < Admin::ApplicationController
  before_filter :set_sponsor, only: %i[show edit update]

  def index
    authorize Sponsor
    @sponsors = Sponsor.all.order(:name)
  end

  def new
    @sponsor = Sponsor.new
    @sponsor.build_address
    @sponsor.contacts.build
    authorize @sponsor
  end

  def create
    @sponsor = Sponsor.new(sponsor_params)
    @sponsor.build_address unless @sponsor.address.present?
    authorize @sponsor
    if @sponsor.save
      flash[:notice] = "Sponsor #{@sponsor.name} created"
      redirect_to [:admin, @sponsor]
    else
      flash[:notice] = @sponsor.errors.full_messages.to_s
      render 'new'
    end
  end

  def edit
    @sponsor = Sponsor.find(params[:id])
    authorize @sponsor
    @sponsor.build_address unless @sponsor.address.present?
    @sponsor.contacts.build
  end

  def update
    @sponsor.update_attributes(sponsor_params)
    redirect_to admin_sponsor_path(@sponsor), notice: 'Updated!'
  end

  private

  def sponsor_params
    params.require(:sponsor).permit(:name, :avatar, :website, :seats, :accessibility_info,
                                    :number_of_coaches, :level, :email, :contact_first_name,
                                    :contact_surname, contact_ids: [], address_attributes:
                                    %i[flat street postal_code city latitude longitude directions])
  end

  def set_sponsor
    @sponsor = Sponsor.find(params[:id])
    authorize @sponsor
  end
end
{'fraction_non_alphanumeric': 0.09642976309642977, 'fraction_numerical': 0.0, 'mean_word_length': 3.3958944281524928, '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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3007403', 'n_tokens_mistral': 1045, 'n_tokens_neox': 944, 'n_words': 210}