Class: Decidim::Proposals::Admin::ProposalNotesController

Inherits:
ApplicationController show all
Defined in:
decidim-proposals/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb

Overview

This controller allows admins to make private notes on proposals in a participatory process.

Instance Method Summary collapse

Methods inherited from Admin::Components::BaseController

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

Methods included from RegistersPermissions

register_permissions

Methods inherited from 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


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb', line 10

def create
  enforce_permission_to :create, :proposal_note, proposal: proposal
  @form = form(ProposalNoteForm).from_params(params)

  CreateProposalNote.call(@form, proposal) do
    on(:ok) do
      flash[:notice] = I18n.t("proposal_notes.create.success", scope: "decidim.proposals.admin")
      redirect_to proposal_path(id: proposal.id)
    end

    on(:invalid) do
      flash.keep[:alert] = I18n.t("proposal_notes.create.error", scope: "decidim.proposals.admin")
      redirect_to proposal_path(id: proposal.id)
    end
  end
end