Sha256: 0005808eec21b2b3ca226d92c03cb095937f0619d67d1dd0a89261385ed4705b

Contents?: true

Size: 1.37 KB

Versions: 33

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    module ParticipatorySpaceExport
      extend ActiveSupport::Concern

      included do
        helper_method :exportable_space

        def create
          enforce_permission_to :create, :export_space, participatory_space: exportable_space

          ExportParticipatorySpaceJob.perform_later(current_user, exportable_space, manifest_name, default_format)

          flash[:notice] = t("decidim.admin.exports.notice")

          redirect_back(fallback_location: after_export_path)
        end

        # Public: To be implemented at the controller. You need to
        # return the space that will be exported.
        def exportable_space
          raise NotImplementedError
        end

        # Public: To be implemented at the controller. You need to
        # return the plural of the name of the space that will be exported.
        def manifest_name
          raise NotImplementedError
        end

        # Public: Returns a String or Object that will be passed to `redirect_to` after
        # exporing a space. By default it redirects to the root_path.
        #
        # It can be redefined at controller level if you need to redirect elsewhere.
        def after_export_path
          decidim.root_path
        end

        private

        def default_format
          "JSON"
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
decidim-admin-0.26.10 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.9 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.8 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.7 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.5 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.4 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.3 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.2 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.1 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.0 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.0.rc2 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.26.0.rc1 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.25.2 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.25.1 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.25.0 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.25.0.rc4 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.25.0.rc3 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.25.0.rc2 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.25.0.rc1 app/controllers/concerns/decidim/admin/participatory_space_export.rb
decidim-admin-0.24.3 app/controllers/concerns/decidim/admin/participatory_space_export.rb