Class: Spotlight::CatalogController

Inherits:
ApplicationController show all
Includes:
Blacklight::Catalog, Catalog
Defined in:
app/controllers/spotlight/catalog_controller.rb

Instance Method Summary collapse

Methods included from Catalog

#blacklight_config

Methods inherited from ApplicationController

#search_action_url

Instance Method Details

#adminObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/spotlight/catalog_controller.rb', line 35

def admin
  self.blacklight_config.view.reject! { |k,v| true }
  self.blacklight_config.view.admin_table.partials = [:index_compact]

  add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
  add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_index_path(@exhibit)
  (@response, @document_list) = get_search_results
  @filters = params[:f] || []
    
  respond_to do |format|
    format.html
  end
end

#editObject



62
63
64
65
66
67
# File 'app/controllers/spotlight/catalog_controller.rb', line 62

def edit
  @document = ::SolrDocument.find(params[:id])
  blacklight_config.view.edit.partials = blacklight_config.view_config(:show).partials.dup
  blacklight_config.view.edit.partials.delete "spotlight/catalog/tags"
  blacklight_config.view.edit.partials.insert(2, :edit)
end

#indexObject



12
13
14
15
16
# File 'app/controllers/spotlight/catalog_controller.rb', line 12

def index
  super

  add_breadcrumb t(:'spotlight.catalog.breadcrumb.index'), request.fullpath if has_search_parameters?
end

#make_privateObject



69
70
71
72
73
74
75
76
77
78
# File 'app/controllers/spotlight/catalog_controller.rb', line 69

def make_private
  @document = ::SolrDocument.find params[:catalog_id] 
  @document.make_private!(current_exhibit)
  @document.save

  respond_to do |format|
    format.html { redirect_to :back }
    format.json { render json: true }
  end
end

#make_publicObject



80
81
82
83
84
85
86
87
88
89
# File 'app/controllers/spotlight/catalog_controller.rb', line 80

def make_public
  @document = ::SolrDocument.find params[:catalog_id] 
  @document.make_public!(current_exhibit)
  @document.save

  respond_to do |format|
    format.html { redirect_to :back }
    format.json { render json: true }
  end
end

#showObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/spotlight/catalog_controller.rb', line 18

def show
  super

  if @document.private? current_exhibit
    authenticate_user!
    authorize! :curate, current_exhibit
  end

  if current_browse_category
    add_breadcrumb t(:'spotlight.browse.nav_link'), exhibit_browse_index_path(current_browse_category.exhibit)
    add_breadcrumb current_browse_category.title, exhibit_browse_path(current_browse_category.exhibit, current_browse_category)
  else
    add_breadcrumb t(:'spotlight.catalog.breadcrumb.index'), search_action_url(current_search_session[:query_params]) if current_search_session
  end
  add_breadcrumb Array(@document[blacklight_config.view_config(:show).title_field]).join(', '), exhibit_catalog_path(@exhibit, @document)
end

#updateObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/spotlight/catalog_controller.rb', line 49

def update
  if params[:solr_document]
    @document = ::SolrDocument.find params[:id] 
    authenticate_user!
    authorize! :curate, current_exhibit
    @document.update(current_exhibit, solr_document_params)
    @document.save
    redirect_to exhibit_catalog_path(current_exhibit, @document)
  else
    super
  end
end