Class: Decidim::Accountability::Admin::StatusesController

Inherits:
ApplicationController show all
Defined in:
decidim-accountability/app/controllers/decidim/accountability/admin/statuses_controller.rb

Overview

This controller allows an admin to manage results from a Participatory Process

Instance Method Summary collapse

Methods inherited from Decidim::Admin::Components::BaseController

#current_component, #current_participatory_space, #parent_path, #permission_class_chain, #permission_scope, #permissions_context, #skip_manage_component_permission

Methods included from RegistersPermissions

register_permissions

Methods inherited from Decidim::Admin::ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'decidim-accountability/app/controllers/decidim/accountability/admin/statuses_controller.rb', line 16

def create
  enforce_permission_to :create, :status

  @form = form(StatusForm).from_params(params)

  CreateStatus.call(@form) do
    on(:ok) do
      flash[:notice] = I18n.t("statuses.create.success", scope: "decidim.accountability.admin")
      redirect_to statuses_path
    end

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

#destroyObject


58
59
60
61
62
63
64
65
66
# File 'decidim-accountability/app/controllers/decidim/accountability/admin/statuses_controller.rb', line 58

def destroy
  enforce_permission_to :destroy, :status, status: status

  status.destroy!

  flash[:notice] = I18n.t("statuses.destroy.success", scope: "decidim.accountability.admin")

  redirect_to statuses_path
end

#editObject


34
35
36
37
38
# File 'decidim-accountability/app/controllers/decidim/accountability/admin/statuses_controller.rb', line 34

def edit
  enforce_permission_to :update, :status, status: status

  @form = form(StatusForm).from_model(status)
end

#newObject


10
11
12
13
14
# File 'decidim-accountability/app/controllers/decidim/accountability/admin/statuses_controller.rb', line 10

def new
  enforce_permission_to :create, :status

  @form = form(StatusForm).instance
end

#updateObject


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'decidim-accountability/app/controllers/decidim/accountability/admin/statuses_controller.rb', line 40

def update
  enforce_permission_to :update, :status, status: status

  @form = form(StatusForm).from_params(params)

  UpdateStatus.call(@form, status) do
    on(:ok) do
      flash[:notice] = I18n.t("statuses.update.success", scope: "decidim.accountability.admin")
      redirect_to statuses_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("statuses.update.invalid", scope: "decidim.accountability.admin")
      render action: "edit"
    end
  end
end