Class: Decidim::EnhancedTextwork::Admin::ParagraphNotesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/enhanced_textwork/admin/paragraph_notes_controller.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  enforce_permission_to :create, :paragraph_note, paragraph: paragraph
  @form = form(ParagraphNoteForm).from_params(params)

  CreateParagraphNote.call(@form, paragraph) do
    on(:ok) do
      flash[:notice] = I18n.t("paragraph_notes.create.success", scope: "decidim.enhanced_textwork.admin")
      redirect_to paragraph_path(id: paragraph.id)
    end

    on(:invalid) do
      flash.keep[:alert] = I18n.t("paragraph_notes.create.error", scope: "decidim.enhanced_textwork.admin")
      redirect_to paragraph_path(id: paragraph.id)
    end
  end
end