Sha256: 519933b78d1581c8bf2dbade4d61b86763023ffc6ff3f854eff6c99b911099b6
Contents?: true
Size: 1.62 KB
Versions: 37
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true module Decidim module Admin # Controller that allows managing the organization homepage class OrganizationHomepageController < Decidim::Admin::ApplicationController layout "decidim/admin/settings" helper_method :active_blocks, :inactive_blocks def edit enforce_permission_to :update, :organization, organization: current_organization end def update enforce_permission_to :update, :organization, organization: current_organization ReorderContentBlocks.call(current_organization, :homepage, params[:manifests]) do on(:ok) do head :ok end on(:invalid) do head :bad_request end end end private def content_blocks @content_blocks ||= Decidim::ContentBlock.for_scope(:homepage, organization: current_organization) end def active_blocks @active_blocks ||= content_blocks.published.where(manifest_name: Decidim.content_blocks.for(:homepage).map(&:name)) end def unpublished_blocks @unpublished_blocks ||= content_blocks.unpublished.where(manifest_name: Decidim.content_blocks.for(:homepage).map(&:name)) end def inactive_blocks @inactive_blocks ||= unpublished_blocks + unused_manifests end def used_manifests @used_manifests ||= content_blocks.map(&:manifest_name) end def unused_manifests @unused_manifests ||= Decidim.content_blocks.for(:homepage).reject do |manifest| used_manifests.include?(manifest.name.to_s) end end end end end
Version data entries
37 entries across 37 versions & 1 rubygems