Sha256: 96f656b534539c8ecec052b871427515bb5d8fe612b7234d8c569d4bc792abab

Contents?: true

Size: 1.48 KB

Versions: 72

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module Decidim
  module Consultations
    module Admin
      # Controller that allows managing consultation result publications.
      class ConsultationResultsPublicationsController < Decidim::Consultations::Admin::ApplicationController
        include ConsultationAdmin

        def create
          enforce_permission_to :publish_results, :consultation, consultation: current_consultation

          PublishConsultationResults.call(current_consultation) do
            on(:ok) do
              flash[:notice] = I18n.t("consultation_results_publications.create.success", scope: "decidim.admin")
            end

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

            redirect_back(fallback_location: consultations_path)
          end
        end

        def destroy
          enforce_permission_to :unpublish_results, :consultation, consultation: current_consultation

          UnpublishConsultationResults.call(current_consultation) do
            on(:ok) do
              flash[:notice] = I18n.t("consultation_results_publications.destroy.success", scope: "decidim.admin")
            end

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

            redirect_back(fallback_location: consultations_path)
          end
        end
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
decidim-consultations-0.26.1 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.26.0 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.26.0.rc2 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.26.0.rc1 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.25.2 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.25.1 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.25.0 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.25.0.rc4 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.25.0.rc3 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.25.0.rc2 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.25.0.rc1 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.24.3 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.23.6 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.24.2 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.23.5 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.24.1 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.24.0 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.24.0.rc2 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.23.4 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb
decidim-consultations-0.24.0.rc1 app/controllers/decidim/consultations/admin/consultation_results_publications_controller.rb