Class: Decidim::Admin::SpacePublicationsController

Inherits:
Decidim::Assemblies::Admin::ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/admin/space_publications_controller.rb

Overview

Base controller that can be inherited by other spaces to publish and unpublish the Space

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/decidim/admin/space_publications_controller.rb', line 8

def create
  enforce_permission_to_publish

  publish_command.call(current_assembly, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("create.success", scope: i18n_scope)
    end

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

    redirect_back(fallback_location: assemblies_path)
  end
end

#destroyObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/decidim/admin/space_publications_controller.rb', line 24

def destroy
  enforce_permission_to_publish

  unpublish_command.call(current_assembly, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("destroy.success", scope: i18n_scope)
    end

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

    redirect_back(fallback_location: assemblies_path)
  end
end