Sha256: ecef822f5fdde7afba69b84a92091b257ee41f2af03bfbda0b8ae9b074bc44c3

Contents?: true

Size: 1014 Bytes

Versions: 11

Compression:

Stored size: 1014 Bytes

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) do
            on(:ok) do
              flash[:notice] = I18n.t("assemblies_copies.create.success", scope: "decidim.admin")
              redirect_to assemblies_path
            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

11 entries across 11 versions & 1 rubygems

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