Sha256: 46fdfd3c333d2c1689c9d2ae8b48ea27228f93f308927f7488d2f23bb476bbb7

Contents?: true

Size: 1.7 KB

Versions: 7

Compression:

Stored size: 1.7 KB

Contents

module Sufia
  module FileSetsControllerBehavior
    extend ActiveSupport::Concern
    include Sufia::Breadcrumbs

    included do
      # prepend this hook so that it comes before load_and_authorize
      prepend_before_action :authenticate_user!, except: [:show, :citation, :stats]
      before_action :build_breadcrumbs, only: [:show, :edit, :stats]

      self.show_presenter = Sufia::FileSetPresenter
      self.form_class = Sufia::Forms::FileSetEditForm
    end

    # routed to /files/:id/stats
    def stats
      @stats = FileUsage.new(params[:id])
    end

    # routed to /files/:id/citation
    def citation
    end

    def add_breadcrumb_for_controller
      add_breadcrumb I18n.t('sufia.dashboard.my.works'), sufia.dashboard_works_path
    end

    def add_breadcrumb_for_action
      case action_name
      when 'edit'.freeze
        add_breadcrumb I18n.t("sufia.file_set.browse_view"), main_app.curation_concerns_file_set_path(params["id"])
      when 'show'.freeze
        add_breadcrumb presenter.parent.to_s, main_app.polymorphic_path(presenter.parent)
        add_breadcrumb presenter.to_s, main_app.polymorphic_path(presenter)
      end
    end

    # This allows us to use the templates in curation_concerns/file_sets
    def self.local_prefixes
      ['curation_concerns/file_sets']
    end

    protected

      def initialize_edit_form
        @version_list = version_list
        super
      end

      def version_list
        original = @file_set.original_file
        versions = original ? original.versions.all : []
        CurationConcerns::VersionListPresenter.new(versions)
      end

      def actor
        @actor ||= CurationConcerns::Actors::FileSetActor.new(@file_set, current_user)
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sufia-7.4.1 app/controllers/concerns/sufia/file_sets_controller_behavior.rb
sufia-7.4.0 app/controllers/concerns/sufia/file_sets_controller_behavior.rb
sufia-7.3.1 app/controllers/concerns/sufia/file_sets_controller_behavior.rb
sufia-7.3.0 app/controllers/concerns/sufia/file_sets_controller_behavior.rb
sufia-7.3.0.rc3 app/controllers/concerns/sufia/file_sets_controller_behavior.rb
sufia-7.3.0.rc2 app/controllers/concerns/sufia/file_sets_controller_behavior.rb
sufia-7.3.0.rc1 app/controllers/concerns/sufia/file_sets_controller_behavior.rb