<commit_before># -*- encoding : utf-8 -*-
require 'blacklight/catalog'

class CatalogController < ApplicationController
  before_filter :authenticate_user!

  include Blacklight::Catalog
  include Hydra::Controller::ControllerBehavior

  # These before_filters apply the hydra access controls
  before_filter :enforce_show_permissions, :only=>:show
  
  # This applies appropriate access controls to all solr queries
  CatalogController.solr_search_params_logic += [:add_access_controls_to_solr_params]

  # This filters out objects that you want to exclude from search results, like FileAssets
  CatalogController.solr_search_params_logic += [:exclude_unwanted_models]
  CatalogController.solr_search_params_logic += [:filter_on_institution]

  def filter_on_institution(solr_parameters, user_parameters)
    if !current_user.is? :admin
      solr_parameters[:fq] ||= []
      solr_parameters[:fq] << '+is_part_of_ssim:' + "\"" + "info:fedora/#{current_user.institution.pid}" + "\""
    end
  end<commit_msg>Fix error in root_path when user is not logged in.<commit_after># -*- encoding : utf-8 -*-
require 'blacklight/catalog'

class CatalogController < ApplicationController

  include Blacklight::Catalog
  include Hydra::Controller::ControllerBehavior

  # These before_filters apply the hydra access controls
  before_filter :enforce_show_permissions, :only=>:show
  
  # This applies appropriate access controls to all solr queries
  CatalogController.solr_search_params_logic += [:add_access_controls_to_solr_params]

  # This filters out objects that you want to exclude from search results, like FileAssets
  CatalogController.solr_search_params_logic += [:exclude_unwanted_models]
  CatalogController.solr_search_params_logic += [:filter_on_institution]

  def filter_on_institution(solr_parameters, user_parameters)
    if current_user and !current_user.is? :admin
      solr_parameters[:fq] ||= []
      solr_parameters[:fq] << '+is_part_of_ssim:' + "\"" + "info:fedora/#{current_user.institution.pid}" + "\""
    end
  end
{'fraction_non_alphanumeric': 0.093811394891945, 'fraction_numerical': 0.0009823182711198428, 'mean_word_length': 5.635179153094462, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '2748308', 'n_tokens_mistral': 628, 'n_tokens_neox': 602, 'n_words': 138}