Class: Decidim::Admin::OrganizationHomepageContentBlocksController

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

Overview

Controller that allows managing the organization homepage content blocks

Instance Method Summary collapse

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

#editObject


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

def edit
  enforce_permission_to :update, :organization, organization: current_organization
  @form = form(ContentBlockForm).from_model(content_block)
end

#updateObject


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

def update
  enforce_permission_to :update, :organization, organization: current_organization
  @form = form(ContentBlockForm).from_params(params)

  UpdateContentBlock.call(@form, content_block, :homepage) do
    on(:ok) do
      redirect_to edit_organization_homepage_path
    end
    on(:invalid) do
      edit # Sets the model to the view so that it can render the form
      render :edit
    end
  end
end