Class: Spotlight::VersionsController

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

Overview

Controller for reverting to historical versions of e.g. pages

Instance Method Summary collapse

Methods included from Concerns::ApplicationController

#enabled_in_spotlight_view_type_configuration?, #field_enabled?

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #default_url_options, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_path, #resource_masthead?, #search_action_url, #search_facet_path, #set_exhibit_locale_scope, #set_locale

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#revertObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/spotlight/versions_controller.rb', line 11

def revert
  obj = @version.reify
  if obj && 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_back fallback_location: main_app.root_url, flash: { html_safe: true }, notice: view_context.t(:'spotlight.versions.undo_error')
  end
end