Sha256: 64a7433957f916c24123e2c93cfdb4e957776c943a194de9da3e49ed84a7d865

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 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, participatory_process

        PublishParticipatoryProcess.call(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, participatory_process

        UnpublishParticipatoryProcess.call(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

10 entries across 10 versions & 2 rubygems

Version Path
decidim-admin-0.4.0 app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-0.4.0 decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-admin-0.3.2 app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-0.3.2 decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-admin-0.3.1 app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-0.3.1 decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-admin-0.3.0 app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-0.3.0 decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-admin-0.2.0 app/controllers/decidim/admin/participatory_process_publications_controller.rb
decidim-0.2.0 decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb