Sha256: 9b2dac09d4f88f4ee8ba4a745a63cb1bc594ead6336db0f7e5efec3ca4e93b56

Contents?: true

Size: 1.04 KB

Versions: 25

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module Admin
      # Controller that allows managing assemblies.
      #
      class AssemblyCopiesController < Decidim::Assemblies::Admin::ApplicationController
        include Concerns::AssemblyAdmin

        def new
          enforce_permission_to :create, :assembly
          @form = form(AssemblyCopyForm).from_model(current_assembly)
        end

        def create
          enforce_permission_to :create, :assembly
          @form = form(AssemblyCopyForm).from_params(params)

          CopyAssembly.call(@form, current_assembly, current_user) do
            on(:ok) do
              flash[:notice] = I18n.t("assemblies_copies.create.success", scope: "decidim.admin")
              redirect_to assemblies_path(parent_id: current_assembly.parent_id)
            end

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-assemblies-0.27.2 app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb
decidim-assemblies-0.27.1 app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb
decidim-assemblies-0.27.0 app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb
decidim-assemblies-0.27.0.rc2 app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb
decidim-assemblies-0.27.0.rc1 app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb