Sha256: 213227ae1db696ec37134e5e3ebd42b2d8f7181c8b3ed985a3bce59acd43b4f1

Contents?: true

Size: 1.4 KB

Versions: 11

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module Decidim
  module Consultations
    module Admin
      # Controller that allows managing question publications.
      class QuestionPublicationsController < Decidim::Consultations::Admin::ApplicationController
        include QuestionAdmin

        def create
          enforce_permission_to :publish, :question, question: current_question

          PublishQuestion.call(current_question) do
            on(:ok) do
              flash[:notice] = I18n.t("question_publications.create.success", scope: "decidim.admin")
            end

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

            redirect_back(fallback_location: consultation_questions_path(current_consultation))
          end
        end

        def destroy
          enforce_permission_to :publish, :question, question: current_question

          UnpublishConsultation.call(current_question) do
            on(:ok) do
              flash[:notice] = I18n.t("question_publications.destroy.success", scope: "decidim.admin")
            end

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

            redirect_back(fallback_location: consultation_questions_path(current_consultation))
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-consultations-0.14.4 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.14.3 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.14.2 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.14.1 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.13.1 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.12.2 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.13.0 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.12.1 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.13.0.pre1 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.12.0 app/controllers/decidim/consultations/admin/question_publications_controller.rb
decidim-consultations-0.12.0.pre app/controllers/decidim/consultations/admin/question_publications_controller.rb