Class: Spotlight::VersionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spotlight/versions_controller.rb

Instance Method Summary collapse

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #default_masthead?, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#revertObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/spotlight/versions_controller.rb', line 7

def revert
  if obj = @version.reify
    authorize! :manage, obj
    if obj.save
      redirect_to [obj.exhibit, obj], flash: { html_safe: true }, notice: undo_link
    else
      redirect_to [obj.exhibit, obj], flash: { html_safe: true }, notice: view_context.t(:'spotlight.versions.undo_error')
    end
  else
    redirect_to :back, flash: { html_safe: true }, notice: view_context.t(:'spotlight.versions.undo_error')
  end

end


21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/spotlight/versions_controller.rb', line 21

def undo_link
  return unless can? :manage, @version

  link_name = if params[:redo] == "true"
    view_context.t(:'spotlight.versions.undo')
  else
    view_context.t(:'spotlight.versions.redo')
  end

  view_context.link_to(link_name, revert_version_path(@version.next, :redo => !params[:redo]), method: :post)
end