Sha256: 90804a0e37a21df89e65eadab0afcd0ba321e1b1d1a06217b47f48cc11112f0c

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require_dependency "decidim/admin/application_controller"

module Decidim
  module Admin
    # Controller that allows managing participatory process publications.
    #
    class ParticipatoryProcessPublicationsController < ApplicationController
      include Concerns::ParticipatoryProcessAdmin

      def create
        authorize! :publish, current_participatory_process

        PublishParticipatoryProcess.call(current_participatory_process) do
          on(:ok) do
            flash[:notice] = I18n.t("participatory_process_publications.create.success", scope: "decidim.admin")
          end

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

          redirect_back(fallback_location: participatory_processes_path)
        end
      end

      def destroy
        authorize! :publish, current_participatory_process

        UnpublishParticipatoryProcess.call(current_participatory_process) do
          on(:ok) do
            flash[:notice] = I18n.t("participatory_process_publications.destroy.success", scope: "decidim.admin")
          end

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

          redirect_back(fallback_location: participatory_processes_path)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
decidim-admin-0.4.2 app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-admin-0.4.1 app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-0.4.2 decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-0.4.1 decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb