Sha256: d64ca880c563d94f8f96176470e65e739c98fe519ebc58525c8e5a95b63a4a6d

Contents?: true

Size: 891 Bytes

Versions: 21

Compression:

Stored size: 891 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

21 entries across 21 versions & 1 rubygems

Version Path
decidim-proposals-0.18.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.17.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.18.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.17.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.16.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.17.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.16.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.15.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.15.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.15.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.14.4 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.14.3 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.14.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.14.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.13.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.12.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.13.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.12.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.13.0.pre1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.12.0 app/controllers/decidim/proposals/application_controller.rb