Class: Decidim::Assemblies::AssembliesController

Inherits:
ApplicationController show all
Includes:
ParticipatorySpaceContext
Defined in:
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

Instance Method Details

#indexObject



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 'app/controllers/decidim/assemblies/assemblies_controller.rb', line 19

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.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 'app/controllers/decidim/assemblies/assemblies_controller.rb', line 45

def show
  check_current_user_can_visit_space
end