Class: Decidim::Sortitions::Sortition
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Sortitions::Sortition
- Includes:
- Authorable, Comments::CommentableWithComponent, FilterableResource, HasCategory, HasComponent, HasReference, Loggable, Randomable, Resourceable, Traceable, TranslatableResource
- Defined in:
- app/models/decidim/sortitions/sortition.rb
Overview
Model that encapsulates the parameters of a sortition
Class Method Summary collapse
Instance Method Summary collapse
-
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` Commentable concern method.
-
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
- #cancelled? ⇒ Boolean
-
#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
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
35 36 37 |
# File 'app/models/decidim/sortitions/sortition.rb', line 35 def self.log_presenter_class_for(_log) Decidim::Sortitions::AdminLog::SortitionPresenter end |
.ransackable_scopes(_auth_object = nil) ⇒ Object
83 84 85 |
# File 'app/models/decidim/sortitions/sortition.rb', line 83 def self.ransackable_scopes(_auth_object = nil) [:with_any_state, :with_category] end |
Instance Method Details
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` Commentable concern method.
60 61 62 |
# File 'app/models/decidim/sortitions/sortition.rb', line 60 def accepts_new_comments? commentable? end |
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
75 76 77 |
# File 'app/models/decidim/sortitions/sortition.rb', line 75 def true end |
#cancelled? ⇒ Boolean
55 56 57 |
# File 'app/models/decidim/sortitions/sortition.rb', line 55 def cancelled? cancelled_on.present? end |
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
65 66 67 |
# File 'app/models/decidim/sortitions/sortition.rb', line 65 def comments_have_alignment? true end |
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
70 71 72 |
# File 'app/models/decidim/sortitions/sortition.rb', line 70 def comments_have_votes? true end |
#proposals ⇒ Object
39 40 41 |
# File 'app/models/decidim/sortitions/sortition.rb', line 39 def proposals Decidim::Proposals::Proposal.where(id: selected_proposals) end |
#seed ⇒ Object
51 52 53 |
# File 'app/models/decidim/sortitions/sortition.rb', line 51 def seed .to_i * dice end |
#similar_count ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/models/decidim/sortitions/sortition.rb', line 43 def similar_count Sortition.where(component:) .where(decidim_proposals_component:) .with_category(category&.id) .where(target_items:) .count end |