Sha256: 1bb390edac29602216c5d6ff9349c09da5d5217fdc0e19d85bb9b6d6f7695ad4

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module Votings
    module Admin
      # This concern is meant to be included in all controllers that are scoped
      # into a voting admin panel. It will override the layout so it shows
      # the sidebar, preload the voting, etc.
      module VotingAdmin
        extend ActiveSupport::Concern

        RegistersPermissions
          .register_permissions(::Decidim::Votings::Admin::VotingAdmin,
                                Decidim::Votings::Permissions,
                                Decidim::Admin::Permissions)

        included do
          include Decidim::Admin::ParticipatorySpaceAdminContext
          helper_method :current_voting
          add_breadcrumb_item_from_menu :admin_voting_menu

          participatory_space_admin_layout

          def current_voting
            @current_voting ||= organization_votings.find_by!(
              slug: params[:voting_slug] || params[:slug]
            )
          end

          alias_method :current_participatory_space, :current_voting

          def organization_votings
            @organization_votings ||= OrganizationVotings.new(current_organization).query
          end

          def permissions_context
            super.merge(current_participatory_space:)
          end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/controllers/concerns/decidim/votings/admin/voting_admin.rb
decidim-elections-0.28.3 app/controllers/concerns/decidim/votings/admin/voting_admin.rb
decidim-elections-0.28.2 app/controllers/concerns/decidim/votings/admin/voting_admin.rb
decidim-elections-0.28.1 app/controllers/concerns/decidim/votings/admin/voting_admin.rb