Sha256: 94b1c5b4401bb725a85f82cae85da5ce0530567099101d1693ef4e75df509be4

Contents?: true

Size: 847 Bytes

Versions: 16

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Plans
    # 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 :plan_limit_reached?

      def plan_limit
        return nil if component_settings.plan_limit.zero?
        component_settings.plan_limit
      end

      def plan_limit_reached?
        return false unless plan_limit

        plans.where(author: current_user).count >= plan_limit
      end

      def plans
        Plan.where(component: current_component)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-plans-0.18.2 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.18.1 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.18.0 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.17.0 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.9 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.8 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.7 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.6 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.5 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.4 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.3 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.2 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.1 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.16.0 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.15.1 app/controllers/decidim/plans/application_controller.rb
decidim-plans-0.15.0 app/controllers/decidim/plans/application_controller.rb