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.26.8 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.27.4 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.27.3 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.7 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.5 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.27.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.27.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.4 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.27.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.3 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.27.0.rc2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.27.0.rc1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.0 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.0.rc2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.26.0.rc1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.25.2 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.25.1 app/controllers/decidim/proposals/application_controller.rb
decidim-proposals-0.25.0 app/controllers/decidim/proposals/application_controller.rb