<commit_before>module Sufia
  module CollectionsControllerBehavior
    extend ActiveSupport::Concern
    include Hydra::CollectionsControllerBehavior

    included do
      include Blacklight::Catalog::SearchContext
      include BlacklightAdvancedSearch::ParseBasicQ
      include BlacklightAdvancedSearch::Controller
      include Sufia::Breadcrumbs

      prepend_before_filter :normalize_identifier, except: [:index, :create, :new]
      before_filter :filter_docs_with_read_access!, except: :show
      before_filter :has_access?, except: :show
      before_filter :initialize_fields_for_edit, only: [:edit, :new]
      before_filter :build_breadcrumbs, only: [:edit, :show]

      self.solr_search_params_logic += [:add_access_controls_to_solr_params]

      layout "sufia-one-column"
    end

    def show
      super
      @presenter = presenter
    end

    protected

    def presenter
      Sufia::CollectionPresenter.new(@collection)
    end

    def collection_params
      params.require(:collection).permit(:title, :description, :members, part_of: [],
        contributor: [], creator: [], publisher: [], date_created: [], subject: [],
        language: [], rights: [], resource_type: [], identifier: [], based_near: [],
        tag: [], related_url: [])
    end

    def query_collection_members
      flash[:notice]=nil if flash[:notice] == "Select something first"
      query = params[:cq]

      #merge in the user parameters and the attach the collection query
      solr_params =  (params.symbolize_keys).merge(q: query)

      # run the solr query to find the collections
      (@response, @member_docs) = get_search_results(solr_params)
    end

    def after_destroy(id)
      respond_to do |format|
        format.html { redirect_to sufia.dashboard_collections_path, notice: 'Collection was successfully deleted.' }
        format.json { render json: {id: id}, status: :destroyed, location: @collection }
      end
    end

    def initialize_fields_for_edit
      @form = Sufia::Forms::CollectionEditForm.new(@collection)
    end

    def _prefixes
      @_prefixes ||= super + ['catalog']
    end
  end
end<commit_msg>Rename #initialize_fields_for_edit to #form on Sufia::CollectionsControllerBehavior This is a more descriptive name for what's being done Fixes #834<commit_after>module Sufia
  module CollectionsControllerBehavior
    extend ActiveSupport::Concern
    include Hydra::CollectionsControllerBehavior

    included do
      include Blacklight::Catalog::SearchContext
      include BlacklightAdvancedSearch::ParseBasicQ
      include BlacklightAdvancedSearch::Controller
      include Sufia::Breadcrumbs

      prepend_before_filter :normalize_identifier, except: [:index, :create, :new]
      before_filter :filter_docs_with_read_access!, except: :show
      before_filter :has_access?, except: :show
      before_filter :build_breadcrumbs, only: [:edit, :show]

      self.solr_search_params_logic += [:add_access_controls_to_solr_params]

      layout "sufia-one-column"
    end

    def new
      super
      form
    end

    def edit
      super
      form
    end

    def show
      super
      presenter
    end

    protected

    def presenter
      @presenter ||= presenter_class.new(@collection)
    end

    def presenter_class
      Sufia::CollectionPresenter
    end

    def collection_params
      params.require(:collection).permit(:title, :description, :members, part_of: [],
        contributor: [], creator: [], publisher: [], date_created: [], subject: [],
        language: [], rights: [], resource_type: [], identifier: [], based_near: [],
        tag: [], related_url: [])
    end

    def query_collection_members
      flash[:notice]=nil if flash[:notice] == "Select something first"
      query = params[:cq]

      #merge in the user parameters and the attach the collection query
      solr_params =  (params.symbolize_keys).merge(q: query)

      # run the solr query to find the collections
      (@response, @member_docs) = get_search_results(solr_params)
    end

    def after_destroy(id)
      respond_to do |format|
        format.html { redirect_to sufia.dashboard_collections_path, notice: 'Collection was successfully deleted.' }
        format.json { render json: {id: id}, status: :destroyed, location: @collection }
      end
    end

    def form
      @form ||= form_class.new(@collection)
    end

    def form_class
      Sufia::Forms::CollectionEditForm
    end

    def _prefixes
      @_prefixes ||= super + ['catalog']
    end
  end
end
{'fraction_non_alphanumeric': 0.0945020975932877, 'fraction_numerical': 0.0006623978803267829, 'mean_word_length': 3.334928229665072, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2403996', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1271, 'n_words': 329}