Sha256: 71ba5a99688174756abe135fb6dd002217f9e6eacb3dafb49b3e305e48151857

Contents?: true

Size: 1.55 KB

Versions: 53

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module Assemblies
    module Admin
      module Concerns
        # This concern is meant to be included in all controllers that are scoped
        # into an assembly's admin panel. It will override the layout so it shows
        # the sidebar, preload the assembly, etc.
        module AssemblyAdmin
          extend ActiveSupport::Concern

          RegistersPermissions
            .register_permissions(::Decidim::Assemblies::Admin::Concerns::AssemblyAdmin,
                                  Decidim::Assemblies::Permissions,
                                  Decidim::Admin::Permissions)

          included do
            include Decidim::Admin::ParticipatorySpaceAdminContext
            participatory_space_admin_layout

            helper_method :current_assembly

            def current_assembly
              @current_assembly ||= organization_assemblies.find_by!(
                slug: params[:assembly_slug] || params[:slug]
              )
            end

            alias_method :current_participatory_space, :current_assembly

            def organization_assemblies
              @organization_assemblies ||= OrganizationAssemblies.new(current_organization).query
            end

            def permissions_context
              super.merge(current_participatory_space: current_participatory_space)
            end

            def permission_class_chain
              PermissionsRegistry.chain_for(AssemblyAdmin)
            end
          end
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
decidim-assemblies-0.27.9 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.8 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.7 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.6 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.26.10 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.26.9 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.5 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.26.8 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.4 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.3 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.26.7 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.26.5 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.2 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.1 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.26.4 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.0 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.26.3 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.0.rc2 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.27.0.rc1 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb
decidim-assemblies-0.26.2 app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb