Sha256: 47b2f21dd8e2747b2176c0458c10860e9fa014a0d81b73265334a97a5c94a4d8

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Decidim
  module ActionDelegator
    module Admin
      module Results
        class SumOfWeightsController < Decidim::Consultations::Admin::ConsultationsController
          def index
            params[:slug] = params[:consultation_slug]

            enforce_permission_to :read, :consultation, consultation: current_consultation

            @questions = Scrutiny.new(current_consultation).questions
            @responses = responses.group_by(&:question_id)
            @total_delegates = DelegatesVotesByConsultation.new(current_consultation).query

            render layout: "decidim/admin/consultation"
          end

          private

          def permission_class_chain
            Decidim.permissions_registry.chain_for(ActionDelegator::Admin::ApplicationController)
          end

          def questions
            current_consultation.questions.published.includes(:responses)
          end

          def responses
            SumOfWeights.new(current_consultation).query
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-action_delegator-0.6.0 app/controllers/decidim/action_delegator/admin/results/sum_of_weights_controller.rb
decidim-action_delegator-0.5.0 app/controllers/decidim/action_delegator/admin/results/sum_of_weights_controller.rb
decidim-action_delegator-0.4.1 app/controllers/decidim/action_delegator/admin/results/sum_of_weights_controller.rb
decidim-action_delegator-0.4 app/controllers/decidim/action_delegator/admin/results/sum_of_weights_controller.rb