Class: Decidim::Budgets::Project
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Budgets::Project
- Includes:
- Comments::CommentableWithComponent, FilterableResource, Followable, HasAttachmentCollections, HasAttachments, HasCategory, HasReference, Loggable, Randomable, Resourceable, ScopableResource, Searchable, SoftDeletable, Taxonomizable, Traceable, TranslatableResource
- Defined in:
- decidim-budgets/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
- .log_presenter_class_for(_log) ⇒ Object
- .ordered_ids(ids) ⇒ Object
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(auth_object = nil) ⇒ Object
- .ransackable_scopes(_auth_object = nil) ⇒ Object
Instance Method Summary collapse
-
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
-
#attachment_context ⇒ Object
Public: Returns the attachment context for this record.
-
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
-
#confirmed_orders_count ⇒ Object
Public: Returns the number of times an specific project have been checked out.
- #polymorphic_resource_path(url_params) ⇒ Object
- #polymorphic_resource_url(url_params) ⇒ Object
- #resource_locator ⇒ Object
-
#selected? ⇒ Boolean
Public: Checks if the project has been selected or not.
-
#users_to_notify_on_comment_created ⇒ Object
Public: Overrides the ‘users_to_notify_on_comment_created` Commentable concern method.
Methods included from Searchable
searchable_resources, searchable_resources_by_type, searchable_resources_of_type_comment, searchable_resources_of_type_component, searchable_resources_of_type_participant, searchable_resources_of_type_participatory_space
Methods included from Followable
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
70 71 72 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 70 def self.log_presenter_class_for(_log) Decidim::Budgets::AdminLog::ProjectPresenter end |
.ordered_ids(ids) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 61 def self.ordered_ids(ids) # Make sure each ID in the matching text has a "," character as their # delimiter. Otherwise e.g. ID 2 would match ID "26" in the original # array. This is why we search for match ",2," instead to get the actual # position for ID 2. concat_ids = connection.quote(",#{ids.join(",")},") order(Arel.sql("position(concat(',', decidim_budgets_projects.id::text, ',') in #{concat_ids})")) end |
.ransackable_associations(_auth_object = nil) ⇒ Object
155 156 157 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 155 def self.ransackable_associations(_auth_object = nil) %w(taxonomies) end |
.ransackable_attributes(auth_object = nil) ⇒ Object
147 148 149 150 151 152 153 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 147 def self.ransackable_attributes(auth_object = nil) base = %w(search_text description title) return base unless auth_object&.admin? base + %w(id_string id selected selected_at confirmed_orders_count) end |
.ransackable_scopes(_auth_object = nil) ⇒ Object
143 144 145 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 143 def self.ransackable_scopes(_auth_object = nil) [:with_any_status, :with_any_taxonomies] end |
Instance Method Details
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
102 103 104 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 102 def component.settings. end |
#attachment_context ⇒ Object
Public: Returns the attachment context for this record.
114 115 116 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 114 def :admin end |
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
87 88 89 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 87 def comments_have_votes? true end |
#confirmed_orders_count ⇒ Object
Public: Returns the number of times an specific project have been checked out.
97 98 99 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 97 def confirmed_orders_count orders.finished.count end |
#polymorphic_resource_path(url_params) ⇒ Object
78 79 80 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 78 def polymorphic_resource_path(url_params) resource_locator.path(url_params) end |
#polymorphic_resource_url(url_params) ⇒ Object
82 83 84 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 82 def polymorphic_resource_url(url_params) resource_locator.url(url_params) end |
#resource_locator ⇒ Object
74 75 76 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 74 def resource_locator ::Decidim::ResourceLocatorPresenter.new([budget, self]) end |
#selected? ⇒ Boolean
Public: Checks if the project has been selected or not.
Returns Boolean.
109 110 111 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 109 def selected? selected_at.present? end |
#users_to_notify_on_comment_created ⇒ Object
Public: Overrides the ‘users_to_notify_on_comment_created` Commentable concern method.
92 93 94 |
# File 'decidim-budgets/app/models/decidim/budgets/project.rb', line 92 def users_to_notify_on_comment_created followers end |