Sha256: a98b70ba9d81fad6c289b7ff0d9400f7abe3eb38db32f99711a9596e402c7ca3

Contents?: true

Size: 1.57 KB

Versions: 14

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    # The data store for a Project in the Decidim::Budgets component. It stores a
    # title, description and any other useful information to render a custom project.
    class Project < Budgets::ApplicationRecord
      include Decidim::Resourceable
      include Decidim::HasFeature
      include Decidim::HasScope
      include Decidim::HasCategory
      include Decidim::HasAttachments
      include Decidim::HasReference
      include Decidim::Comments::Commentable

      feature_manifest_name "budgets"
      has_many :line_items, class_name: "Decidim::Budgets::LineItem", foreign_key: "decidim_project_id", dependent: :destroy
      has_many :orders, through: :line_items, foreign_key: "decidim_project_id", class_name: "Decidim::Budgets::Order"

      # Public: Overrides the `commentable?` Commentable concern method.
      def commentable?
        feature.settings.comments_enabled?
      end

      # Public: Overrides the `accepts_new_comments?` Commentable concern method.
      def accepts_new_comments?
        commentable? && !feature.active_step_settings.comments_blocked
      end

      # Public: Overrides the `comments_have_votes?` Commentable concern method.
      def comments_have_votes?
        true
      end

      # Public: Returns the number of times an specific project have been checked out.
      def confirmed_orders_count
        orders.finished.count
      end

      # Public: Overrides the `notifiable?` Notifiable concern method.
      def notifiable?(_context)
        false
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
decidim-budgets-0.5.1 app/models/decidim/budgets/project.rb
decidim-0.5.1 decidim-budgets/app/models/decidim/budgets/project.rb
decidim-budgets-0.5.0 app/models/decidim/budgets/project.rb
decidim-0.5.0 decidim-budgets/app/models/decidim/budgets/project.rb
decidim-budgets-0.4.4 app/models/decidim/budgets/project.rb
decidim-0.4.4 decidim-budgets/app/models/decidim/budgets/project.rb
decidim-budgets-0.4.3 app/models/decidim/budgets/project.rb
decidim-budgets-0.4.2 app/models/decidim/budgets/project.rb
decidim-budgets-0.4.1 app/models/decidim/budgets/project.rb
decidim-0.4.3 decidim-budgets/app/models/decidim/budgets/project.rb
decidim-0.4.2 decidim-budgets/app/models/decidim/budgets/project.rb
decidim-0.4.1 decidim-budgets/app/models/decidim/budgets/project.rb
decidim-budgets-0.4.0 app/models/decidim/budgets/project.rb
decidim-0.4.0 decidim-budgets/app/models/decidim/budgets/project.rb