<commit_before>class EntriesController < ApplicationController
#  respond_to :html, :json
  autocomplete :entry, :term, :class_name => Entry.translation_class, :full => true, :scopes => [:accessible]

  before_filter :login_required, :except => [:show, :index, :autocomplete_entry_term]
  before_filter :find_entry, :except => [:index, :new, :create]
  before_filter :authorize, :only => [:destroy, :update, :edit, :approve]

  def show
  end

  def new
    @entry = Entry.new
  end

  def create
    @entry = Entry.new(params[:entry])
    @entry.user_id = current_user.id
    if @entry.save
      flash[:success] = "New glossary entry has been created."
      redirect_to @entry
    else
      flash.now[:error] = "There were errors in the information entered."
      render "new"
    end
  end

  def update
    respond_to do |format|
      if (@entry.update_attributes(params[:entry]))
#        format.json { respond_with_bip(@entry) }
        format.html {
          flash[:success] = "Entry \"#{@entry.term_in_glossary_language}\" has been updated."
          redirect_to @entry
        }
      else
#        format.json { respond_with_bip(@entry) }
        format.html { 
          flash.now[:error] = "Entry could not be updated."
          render "edit"
        }
      end
    end
  end

  def approve
    if @entry.update_attributes({ :approved => params[:entry][:approved] }, :as => :manager)
      flash[:success] = "Entry \"#{@entry.term_in_glossary_language}\" has been #{(@entry.approved == true) ? "approved" : "unapproved"}."
    else
      flash[:error] = "Entry \"#{@entry.term_in_glossary_language}\" approval status was not changed."
    end
    redirect_to :back
  end

  def edit
  end

  def destroy
    term = @entry.term_in_glossary_language
    if @entry.destroy
      flash[:success] = "Entry \"#{term}\" has been deleted."
    end
    redirect_to entries_path
  end

  def index
    scope = (logged_in?) ? Entry.scoped : Entry.where(approved: true)
    scope = scope.includes(:user).with_translations(base_languages)<commit_msg>quick fix for #20<commit_after>class EntriesController < ApplicationController
#  respond_to :html, :json
  autocomplete :entry, :term, :class_name => Entry.translation_class, :full => true, :scopes => [:accessible]

  before_filter :login_required, :except => [:show, :index, :autocomplete_entry_term]
  before_filter :find_entry, :except => [:index, :new, :create]
  before_filter :authorize, :only => [:destroy, :update, :edit, :approve]

  def show
  end

  def new
    @entry = Entry.new
  end

  def create
    @entry = Entry.new(params[:entry])
    @entry.user_id = current_user.id
    if @entry.save
      flash[:success] = "New glossary entry has been created."
      redirect_to @entry
    else
      flash.now[:error] = "There were errors in the information entered."
      render "new"
    end
  end

  def update
    respond_to do |format|
      if (@entry.update_attributes(params[:entry]))
#        format.json { respond_with_bip(@entry) }
        format.html {
          flash[:success] = "Entry \"#{@entry.term_in_glossary_language}\" has been updated."
          redirect_to @entry
        }
      else
#        format.json { respond_with_bip(@entry) }
        format.html { 
          flash.now[:error] = "Entry could not be updated."
          render "edit"
        }
      end
    end
  end

  def approve
    if @entry.update_attributes({ :approved => params[:entry][:approved] }, :as => :manager)
      flash[:success] = "Entry \"#{@entry.term_in_glossary_language}\" has been #{(@entry.approved == true) ? "approved" : "unapproved"}."
    else
      flash[:error] = "Entry \"#{@entry.term_in_glossary_language}\" approval status was not changed."
    end
    redirect_to :back
  end

  def edit
  end

  def destroy
    term = @entry.term_in_glossary_language
    if @entry.destroy
      flash[:success] = "Entry \"#{term}\" has been deleted."
    end
    if !(request.referrer.blank?)
      redirect_to '/entries' + (request.referrer.slice(/\?.*/) || "")
    else
      redirect_to entries_path
    end
  end

  def index
    scope = (logged_in?) ? Entry.scoped : Entry.where(approved: true)
    scope = scope.includes(:user).with_translations(base_languages)
{'fraction_non_alphanumeric': 0.130865361942938, 'fraction_numerical': 0.0004715868898844612, 'mean_word_length': 3.013245033112583, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1542412', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1334, 'n_words': 335}