Sha256: e0c000bdfd77184e6b1b06fe33d6411873f398289df1b688c90700fe2153e230
Contents?: true
Size: 1.25 KB
Versions: 29
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Spotlight ## # Controller for reverting to historical versions of e.g. pages class VersionsController < Spotlight::ApplicationController before_action :authenticate_user! load_and_authorize_resource class: 'PaperTrail::Version' 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 private 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]), data: { method: :post, turbo_method: :post }) end end end
Version data entries
29 entries across 29 versions & 1 rubygems