Class: Decidim::Sortitions::Sortition
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Sortitions::Sortition
- Includes:
- Authorable, Comments::CommentableWithComponent, FilterableResource, HasCategory, HasComponent, HasReference, Loggable, Randomable, Resourceable, Taxonomizable, Traceable, TranslatableResource
- Defined in:
- decidim-sortitions/app/models/decidim/sortitions/sortition.rb
Overview
Model that encapsulates the parameters of a sortition
Class Method Summary collapse
- .log_presenter_class_for(_log) ⇒ Object
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(_auth_object = nil) ⇒ Object
- .ransackable_scopes(_auth_object = nil) ⇒ Object
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
Methods included from TranslatableAttributes
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
36 37 38 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 36 def self.log_presenter_class_for(_log) Decidim::Sortitions::AdminLog::SortitionPresenter end |
.ransackable_associations(_auth_object = nil) ⇒ Object
94 95 96 97 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 94 def self.ransackable_associations(_auth_object = nil) %w(author cancelled_by_user taxonomies comment_threads comments component decidim_proposals_component resource_links_from resource_links_to resource_permission user_group versions) end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
88 89 90 91 92 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 88 def self.ransackable_attributes(_auth_object = nil) %w(additional_info cancel_reason cancelled_by_user_id cancelled_on candidate_proposals comments_count created_at decidim_author_id decidim_author_type decidim_component_id decidim_proposals_component_id dice id reference request_timestamp search_text selected_proposals target_items title updated_at witnesses) end |
.ransackable_scopes(_auth_object = nil) ⇒ Object
84 85 86 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 84 def self.ransackable_scopes(_auth_object = nil) [:with_any_state, :with_any_taxonomies] end |
Instance Method Details
#accepts_new_comments? ⇒ Boolean
Public: Overrides the ‘accepts_new_comments?` Commentable concern method.
61 62 63 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 61 def accepts_new_comments? commentable? end |
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
76 77 78 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 76 def true end |
#cancelled? ⇒ Boolean
56 57 58 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 56 def cancelled? cancelled_on.present? end |
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
66 67 68 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 66 def comments_have_alignment? true end |
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
71 72 73 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 71 def comments_have_votes? true end |
#proposals ⇒ Object
40 41 42 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 40 def proposals Decidim::Proposals::Proposal.where(id: selected_proposals) end |
#seed ⇒ Object
52 53 54 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 52 def seed .to_i * dice end |
#similar_count ⇒ Object
44 45 46 47 48 49 50 |
# File 'decidim-sortitions/app/models/decidim/sortitions/sortition.rb', line 44 def similar_count Sortition.where(component:) .where(decidim_proposals_component:) .with_taxonomies(*taxonomies.map(&:id)) .where(target_items:) .count end |