Class: Decidim::Sortitions::Sortition
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Sortitions::Sortition
- Includes:
- Authorable, Comments::Commentable, HasCategory, HasComponent, HasReference, Loggable, Randomable, Resourceable, Traceable, TranslatableResource
- Defined in:
- app/models/decidim/sortitions/sortition.rb
Overview
Model that encapsulates the parameters of a sortion
Class Method Summary collapse
Instance Method Summary collapse
-
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` Commentable concern method.
- #cancelled? ⇒ Boolean
-
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
-
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
-
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
- #proposals ⇒ Object
- #seed ⇒ Object
- #similar_count ⇒ Object
-
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
37 38 39 |
# File 'app/models/decidim/sortitions/sortition.rb', line 37 def self.log_presenter_class_for(_log) Decidim::Sortitions::AdminLog::SortitionPresenter end |
Instance Method Details
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` Commentable concern method.
67 68 69 |
# File 'app/models/decidim/sortitions/sortition.rb', line 67 def accepts_new_comments? commentable? end |
#cancelled? ⇒ Boolean
57 58 59 |
# File 'app/models/decidim/sortitions/sortition.rb', line 57 def cancelled? cancelled_on.present? end |
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
62 63 64 |
# File 'app/models/decidim/sortitions/sortition.rb', line 62 def commentable? component.settings.comments_enabled? end |
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
72 73 74 |
# File 'app/models/decidim/sortitions/sortition.rb', line 72 def comments_have_alignment? true end |
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
77 78 79 |
# File 'app/models/decidim/sortitions/sortition.rb', line 77 def comments_have_votes? true end |
#proposals ⇒ Object
41 42 43 |
# File 'app/models/decidim/sortitions/sortition.rb', line 41 def proposals Decidim::Proposals::Proposal.where(id: selected_proposals) end |
#seed ⇒ Object
53 54 55 |
# File 'app/models/decidim/sortitions/sortition.rb', line 53 def seed .to_i * dice end |
#similar_count ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/models/decidim/sortitions/sortition.rb', line 45 def similar_count Sortition.where(component: component) .where(decidim_proposals_component: decidim_proposals_component) .categorized_as(category&.id) .where(target_items: target_items) .count end |
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
82 83 84 |
# File 'app/models/decidim/sortitions/sortition.rb', line 82 def user_allowed_to_comment?(user) can_participate_in_space?(user) end |