Sha256: 6afe78a000dff7b13c73766698c33d8587604ae294914349ee47a416fbee39bc

Contents?: true

Size: 892 Bytes

Versions: 64

Compression:

Stored size: 892 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    # This controller is the abstract class from which all other controllers of
    # this engine inherit.
    #
    # Note that it inherits from `Decidim::Components::BaseController`, which
    # override its layout and provide all kinds of useful methods.
    class ApplicationController < Decidim::Components::BaseController
      helper Decidim::Messaging::ConversationHelper
      helper_method :proposal_limit_reached?

      def proposal_limit
        return nil if component_settings.proposal_limit.zero?

        component_settings.proposal_limit
      end

      def proposal_limit_reached?
        return false unless proposal_limit

        proposals.where(author: current_user).count >= proposal_limit
      end

      def proposals
        Proposal.where(component: current_component)
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
decidim-proposals-0.25.0.rc4 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.25.0.rc3 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.25.0.rc2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.25.0.rc1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.24.3 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.23.6 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.24.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.23.5 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.24.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.24.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.24.0.rc2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.23.4 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.24.0.rc1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.23.3 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.23.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.23.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.23.1.rc1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.23.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.22.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.21.0 app/controllers/decidim/proposals/application_controller.rb