Sha256: 57727b6de885259fceac6ba91e177e8cfb176eed3722c3d826df6f2f93312778
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Decidim module ParticipatoryDocuments class SectionSuggestionsController < Decidim::ParticipatoryDocuments::ApplicationController include FormFactory include Paginable helper_method :section, :suggestions layout false def index enforce_permission_to :create, :suggestion @form = form(Decidim::ParticipatoryDocuments::SuggestionForm).instance end def create enforce_permission_to :create, :suggestion @form = form(Decidim::ParticipatoryDocuments::SuggestionForm).from_params(params) CreateSuggestion.call(@form, section) do on(:ok) do |_suggestion| redirect_to(document_section_suggestions_path(document, section.id)) && return end on(:invalid) do render template: "decidim/participatory_documents/section_suggestions/index", format: [:html], status: :bad_request end end end private def suggestions @suggestions ||= section.suggestions.where(author: current_user).order(created_at: :asc) end def section @section ||= document.sections.find(params[:section_id]) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems