Class: Decidim::Assemblies::AssembliesController

Inherits:
ApplicationController show all
Includes:
AssemblyBreadcrumb, FilterResource, HasParticipatorySpaceContentBlocks, Paginable, ParticipatorySpaceContext
Defined in:
decidim-assemblies/app/controllers/decidim/assemblies/assemblies_controller.rb

Overview

A controller that holds the logic to show Assemblies in a public layout.

Constant Summary

Constants included from Paginable

Paginable::OPTIONS

Instance Method Summary collapse

Methods included from RegistersPermissions

register_permissions

Methods inherited from Decidim::ApplicationController

#store_share_token

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from TranslatableAttributes

#default_locale?

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#indexObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'decidim-assemblies/app/controllers/decidim/assemblies/assemblies_controller.rb', line 15

def index
  enforce_permission_to :list, :assembly

  respond_to do |format|
    format.html do
      raise ActionController::RoutingError, "Not Found" if published_assemblies.none?

      render "index"
    end

    format.js do
      raise ActionController::RoutingError, "Not Found" if published_assemblies.none?

      render "index"
    end

    format.json do
      render json: published_assemblies.query.includes(:children).where(parent: nil).collect { |assembly|
        {
          name: assembly.title[I18n.locale.to_s],
          children: assembly.children.collect do |child|
            {
              name: child.title[I18n.locale.to_s],
              children: child.children.collect { |child_of_child| { name: child_of_child.title[I18n.locale.to_s] } }
            }
          end
        }
      }
    end
  end
end

#showObject



47
48
49
# File 'decidim-assemblies/app/controllers/decidim/assemblies/assemblies_controller.rb', line 47

def show
  enforce_permission_to :read, :assembly, assembly: current_participatory_space
end