<commit_before>class CiniiBooksController < ApplicationController
  before_filter :authenticate_user!
  before_filter :check_librarian

  def index
    if params[:page].to_i == 0
      page = 1
    else
      page = params[:page]
    end
    @query = params[:query].to_s.strip
    books = CiniiBook.search(params[:query], page)
    @books = Kaminari.paginate_array(
      books[:items], :total_count => books[:total_entries], :page => page
    ).page(page).per(10)

    respond_to do |format|
      format.html
    end
  end

  def create
    if params[:book]
      @manifestation = CiniiBook.import_ncid(params[:book][:ncid])
      respond_to do |format|
        if @manifestation.try(:save)
          flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.manifestation'))
          format.html { redirect_to manifestation_items_url(@manifestation) }
        else
          flash[:notice] = t('enju_nii.record_not_found')
          format.html { redirect_to cinii_books_url }
        end
      end
    end
  #rescue ActiveRecord::RecordInvalid => e
  #  respond_to do |format|
  #    flash[:notice] = e.message
  #    format.html { render :action => "index" }
  #  end
  end

  private
  def check_librarian
    unless current_user.try(:has_role?, 'Librarian')
      access_denied
    end
  end
end
<commit_msg>update redirect url for manifestation_url.<commit_after>class CiniiBooksController < ApplicationController
  before_filter :authenticate_user!
  before_filter :check_librarian

  def index
    if params[:page].to_i == 0
      page = 1
    else
      page = params[:page]
    end
    @query = params[:query].to_s.strip
    books = CiniiBook.search(params[:query], page)
    @books = Kaminari.paginate_array(
      books[:items], :total_count => books[:total_entries], :page => page
    ).page(page).per(10)

    respond_to do |format|
      format.html
    end
  end

  def create
    if params[:book]
      @manifestation = CiniiBook.import_ncid(params[:book][:ncid])
      respond_to do |format|
        if @manifestation.try(:save)
          flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.manifestation'))
          format.html { redirect_to manifestation_url(@manifestation) }
        else
          flash[:notice] = t('enju_nii.record_not_found')
          format.html { redirect_to cinii_books_url }
        end
      end
    end
  #rescue ActiveRecord::RecordInvalid => e
  #  respond_to do |format|
  #    flash[:notice] = e.message
  #    format.html { render :action => "index" }
  #  end
  end

  private
  def check_librarian
    unless current_user.try(:has_role?, 'Librarian')
      access_denied
    end
  end
end

{'fraction_non_alphanumeric': 0.11168448212311095, 'fraction_numerical': 0.002948765204570586, 'mean_word_length': 2.9911764705882353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '6803026', 'n_tokens_mistral': 884, 'n_tokens_neox': 850, 'n_words': 180}