Sha256: 99b9c97ff32ae333328d29ed233702aefb3fb34e8e75b27271112e56bb43f4a0

Contents?: true

Size: 1.78 KB

Versions: 25

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true
module Hyrax
  class Admin::CollectionTypeParticipantsController < ApplicationController
    before_action do
      authorize! :manage, :collection_types
    end

    class_attribute :form_class
    self.form_class = Hyrax::Forms::Admin::CollectionTypeParticipantForm

    def create
      @collection_type_participant = Hyrax::CollectionTypeParticipant.new(collection_type_participant_params)
      if @collection_type_participant.save
        redirect_to(
          edit_admin_collection_type_path(@collection_type_participant.hyrax_collection_type_id, anchor: 'participants'),
          notice: I18n.t('update_notice', scope: 'hyrax.admin.collection_types.form_participants')
        )
      else
        redirect_to(
          edit_admin_collection_type_path(@collection_type_participant.hyrax_collection_type_id, anchor: 'participants'),
          alert: @collection_type_participant.errors.full_messages.to_sentence
        )
      end
    end

    def destroy
      @collection_type_participant = Hyrax::CollectionTypeParticipant.find(params[:id])
      if @collection_type_participant.destroy
        redirect_to(
          edit_admin_collection_type_path(@collection_type_participant.hyrax_collection_type_id, anchor: 'participants'),
          notice: I18n.t('remove_success', scope: 'hyrax.admin.collection_types.form_participants')
        )
      else
        redirect_to(
          edit_admin_collection_type_path(@collection_type_participant.hyrax_collection_type_id, anchor: 'participants'),
          alert: @collection_type_participant.errors.full_messages.to_sentence
        )
      end
    end

    def collection_type_participant_params
      params.require(:collection_type_participant).permit(:access, :agent_id, :agent_type, :hyrax_collection_type_id)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
hyrax-3.0.1 app/controllers/hyrax/admin/collection_type_participants_controller.rb
hyrax-3.0.0 app/controllers/hyrax/admin/collection_type_participants_controller.rb
hyrax-3.0.0.pre.rc4 app/controllers/hyrax/admin/collection_type_participants_controller.rb
hyrax-3.0.0.pre.rc3 app/controllers/hyrax/admin/collection_type_participants_controller.rb
hyrax-3.0.0.pre.rc2 app/controllers/hyrax/admin/collection_type_participants_controller.rb