Class: Decidim::Budgets::Project

Inherits:
ApplicationRecord show all
Includes:
Comments::Commentable, Followable, HasAttachmentCollections, HasAttachments, HasCategory, HasComponent, HasReference, Loggable, Randomable, Resourceable, ScopableComponent, Searchable, 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



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

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)


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

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)


64
65
66
# File 'app/models/decidim/budgets/project.rb', line 64

def allow_resource_permissions?
  component.settings.resources_permissions_enabled
end

#commentable?Boolean

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

Returns:

  • (Boolean)


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

def commentable?
  component.settings.comments_enabled?
end

#comments_have_votes?Boolean

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

Returns:

  • (Boolean)


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

def comments_have_votes?
  true
end

#confirmed_orders_countObject

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



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

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)


69
70
71
# File 'app/models/decidim/budgets/project.rb', line 69

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.



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

def users_to_notify_on_comment_created
  followers
end