Sha256: 57066c21e91d5530cdc050a2e84f9721f789376286afe7a9cf0b0e3069c98222

Contents?: true

Size: 1.38 KB

Versions: 72

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module Admin
      # Controller that allows managing assembly publications.
      #
      class AssemblyPublicationsController < Decidim::Assemblies::Admin::ApplicationController
        include Concerns::AssemblyAdmin

        def create
          enforce_permission_to :publish, :assembly, assembly: current_assembly

          PublishAssembly.call(current_assembly, current_user) do
            on(:ok) do
              flash[:notice] = I18n.t("assembly_publications.create.success", scope: "decidim.admin")
            end

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

            redirect_back(fallback_location: assemblies_path)
          end
        end

        def destroy
          enforce_permission_to :publish, :assembly, assembly: current_assembly

          UnpublishAssembly.call(current_assembly, current_user) do
            on(:ok) do
              flash[:notice] = I18n.t("assembly_publications.destroy.success", scope: "decidim.admin")
            end

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

            redirect_back(fallback_location: assemblies_path)
          end
        end
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
decidim-assemblies-0.27.9 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.8 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.7 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.6 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.26.10 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.26.9 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.5 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.26.8 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.4 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.3 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.26.7 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.26.5 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.2 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.1 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.26.4 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.0 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.26.3 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.0.rc2 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.27.0.rc1 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb
decidim-assemblies-0.26.2 app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb