Class: Decidim::Admin::SpacePublicationsController

Inherits:
ApplicationController 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 Participatory Space

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

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_participatory_space, 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:)
  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_participatory_space, 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:)
  end
end