Class: Workarea::Admin::TrashController
- Inherits:
-
ApplicationController
- Object
- Workarea::ApplicationController
- ApplicationController
- Workarea::Admin::TrashController
- Defined in:
- app/controllers/workarea/admin/trash_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model
Methods included from Publishing
#allow_publishing!, #allow_publishing?, #set_publishing_options
Methods included from Visiting
Instance Method Details
#index ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/controllers/workarea/admin/trash_controller.rb', line 6 def index @entries = Mongoid::AuditLog::Entry .all .destroys .where(restored: false) .desc(:created_at) .page(params[:page]) end |
#restore ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/workarea/admin/trash_controller.rb', line 15 def restore entry = Mongoid::AuditLog::Entry.find(params[:id]) entry.restore! flash[:success] = t('workarea.admin.trash.flash_messages.success') redirect_to( if entry.audited.is_a?(Content::Block) edit_content_path(entry.root) elsif entry.audited.is_a?(Navigation::Taxon) (taxon_ids: entry.audited.parent_ids) elsif entry.audited.is_a?(Comment) commentable_comments_path(entry.root.commentable.to_global_id) else polymorphic_path(entry.root) end ) rescue Mongoid::Errors::Validations => e flash[:error] = e.document.errors.to_a.to_sentence redirect_back fallback_location: trash_index_path rescue Mongoid::AuditLog::Restore::InvalidRestore flash[:error] = t('workarea.admin.trash.flash_messages.error') redirect_back fallback_location: trash_index_path end |