Class: Decidim::Budgets::Project

Inherits:
ApplicationRecord show all
Includes:
Comments::Commentable, Followable, HasAttachmentCollections, HasAttachments, HasCategory, HasComponent, HasReference, Loggable, Randomable, Resourceable, ScopableComponent, Traceable
Defined in:
app/models/decidim/budgets/project.rb

Overview

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 Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log_presenter_class_for(_log) ⇒ Object



25
26
27
# File 'app/models/decidim/budgets/project.rb', line 25

def self.log_presenter_class_for(_log)
  Decidim::Budgets::AdminLog::ProjectPresenter
end

Instance Method Details

#accepts_new_comments?Boolean

Public: Overrides the ‘accepts_new_comments?` Commentable concern method.

Returns:

  • (Boolean)


35
36
37
# File 'app/models/decidim/budgets/project.rb', line 35

def accepts_new_comments?
  commentable? && !component.current_settings.comments_blocked
end

#allow_resource_permissions?Boolean

Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.

Returns:

  • (Boolean)


55
56
57
# File 'app/models/decidim/budgets/project.rb', line 55

def allow_resource_permissions?
  component.settings.resources_permissions_enabled
end

#commentable?Boolean

Public: Overrides the ‘commentable?` Commentable concern method.

Returns:

  • (Boolean)


30
31
32
# File 'app/models/decidim/budgets/project.rb', line 30

def commentable?
  component.settings.comments_enabled?
end

#comments_have_votes?Boolean

Public: Overrides the ‘comments_have_votes?` Commentable concern method.

Returns:

  • (Boolean)


40
41
42
# File 'app/models/decidim/budgets/project.rb', line 40

def comments_have_votes?
  true
end

#confirmed_orders_countObject

Public: Returns the number of times an specific project have been checked out.



50
51
52
# File 'app/models/decidim/budgets/project.rb', line 50

def confirmed_orders_count
  orders.finished.count
end

#user_allowed_to_comment?(user) ⇒ Boolean

Public: Whether the object can have new comments or not.

Returns:

  • (Boolean)


60
61
62
# File 'app/models/decidim/budgets/project.rb', line 60

def user_allowed_to_comment?(user)
  can_participate_in_space?(user)
end

#users_to_notify_on_comment_createdObject

Public: Overrides the ‘users_to_notify_on_comment_created` Commentable concern method.



45
46
47
# File 'app/models/decidim/budgets/project.rb', line 45

def users_to_notify_on_comment_created
  followers
end