Class: Decidim::Assemblies::AssembliesController

Inherits:
ApplicationController show all
Includes:
FilterResource, 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.

Instance Method Summary collapse

Methods included from RegistersPermissions

register_permissions

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#indexObject


13
14
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
# File 'decidim-assemblies/app/controllers/decidim/assemblies/assemblies_controller.rb', line 13

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


45
46
47
# File 'decidim-assemblies/app/controllers/decidim/assemblies/assemblies_controller.rb', line 45

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