Sha256: 8af0259c9c2e049bac0184b7f64aac5ed53bf3b4e933140c0f30c947affe5448

Contents?: true

Size: 1.83 KB

Versions: 22

Compression:

Stored size: 1.83 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # Controller that allows managing registration type publications.
      #
      class RegistrationTypePublicationsController < Decidim::Conferences::Admin::ApplicationController
        include Concerns::ConferenceAdmin

        def create
          @registration_type = collection.find(params[:registration_type_id])
          enforce_permission_to :publish, :registration_type, registration_type: @registration_type

          PublishRegistrationType.call(@registration_type, current_user) do
            on(:ok) do
              flash[:notice] = I18n.t("registration_type_publications.create.success", scope: "decidim.admin")
            end

            on(:invalid) do
              flash[:alert] = I18n.t("registration_type_publications.create.error", scope: "decidim.admin")
            end

            redirect_back(fallback_location: conference_registration_types_path(current_conference))
          end
        end

        def destroy
          @registration_type = collection.find(params[:registration_type_id])
          enforce_permission_to :unpublish, :registration_type, registration_type: @registration_type

          UnpublishRegistrationType.call(@registration_type, current_user) do
            on(:ok) do
              flash[:notice] = I18n.t("registration_type_publications.destroy.success", scope: "decidim.admin")
            end

            on(:invalid) do
              flash[:alert] = I18n.t("registration_type_publications.destroy.error", scope: "decidim.admin")
            end

            redirect_back(fallback_location: conference_registration_types_path(current_conference))
          end
        end

        private

        def collection
          @collection ||= current_conference.registration_types
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
decidim-conferences-0.29.1 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.28.4 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.27.9 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.29.0 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.28.3 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.27.8 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.29.0.rc4 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.29.0.rc3 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.29.0.rc2 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.29.0.rc1 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.28.2 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.27.7 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.28.1 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.27.6 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.26.10 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.26.9 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.28.0 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.27.5 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.28.0.rc5 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb
decidim-conferences-0.28.0.rc4 app/controllers/decidim/conferences/admin/registration_type_publications_controller.rb