Class: Decidim::CollaborativeTexts::DocumentsController

Inherits:
ApplicationController
  • Object
show all
Includes:
AjaxPermissionHandler, FormFactory, Paginable
Defined in:
app/controllers/decidim/collaborative_texts/documents_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



12
# File 'app/controllers/decidim/collaborative_texts/documents_controller.rb', line 12

def index; end

#showObject

Raises:

  • (ActionController::RoutingError)


14
15
16
# File 'app/controllers/decidim/collaborative_texts/documents_controller.rb', line 14

def show
  raise ActionController::RoutingError, "Not Found" unless document
end

#updateObject

roll out a new version of the document (only admins)



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/decidim/collaborative_texts/documents_controller.rb', line 19

def update
  enforce_permission_to(:rollout, :collaborative_text, document:)

  @form = form(RolloutForm).from_params(params, document:)
  Rollout.call(@form) do
    on(:ok) do
      render json: { redirect: @form.draft? ? presenter.edit : presenter.path }
    end

    on(:invalid) do
      render json: { message: I18n.t("document.rollout.invalid", scope: "decidim.collaborative_texts", errors: @form.errors.full_messages) }, status: :unprocessable_content
    end
  end
end