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, Traceable, TranslatableResource
- 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
- .log_presenter_class_for(_log) ⇒ Object
- .ordered_ids(ids) ⇒ 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.
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
68 69 70 |
# File 'app/models/decidim/budgets/project.rb', line 68 def self.log_presenter_class_for(_log) Decidim::Budgets::AdminLog::ProjectPresenter end |
.ordered_ids(ids) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/models/decidim/budgets/project.rb', line 59 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_scopes(_auth_object = nil) ⇒ Object
141 142 143 |
# File 'app/models/decidim/budgets/project.rb', line 141 def self.ransackable_scopes(_auth_object = nil) [:with_any_status, :with_any_scope, :with_any_category] end |
Instance Method Details
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
100 101 102 |
# File 'app/models/decidim/budgets/project.rb', line 100 def component.settings. end |
#attachment_context ⇒ Object
Public: Returns the attachment context for this record.
112 113 114 |
# File 'app/models/decidim/budgets/project.rb', line 112 def :admin end |
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
85 86 87 |
# File 'app/models/decidim/budgets/project.rb', line 85 def comments_have_votes? true end |
#confirmed_orders_count ⇒ Object
Public: Returns the number of times an specific project have been checked out.
95 96 97 |
# File 'app/models/decidim/budgets/project.rb', line 95 def confirmed_orders_count orders.finished.count end |
#polymorphic_resource_path(url_params) ⇒ Object
76 77 78 |
# File 'app/models/decidim/budgets/project.rb', line 76 def polymorphic_resource_path(url_params) resource_locator.path(url_params) end |
#polymorphic_resource_url(url_params) ⇒ Object
80 81 82 |
# File 'app/models/decidim/budgets/project.rb', line 80 def polymorphic_resource_url(url_params) resource_locator.url(url_params) end |
#resource_locator ⇒ Object
72 73 74 |
# File 'app/models/decidim/budgets/project.rb', line 72 def resource_locator ::Decidim::ResourceLocatorPresenter.new([budget, self]) end |
#selected? ⇒ Boolean
Public: Checks if the project has been selected or not.
Returns Boolean.
107 108 109 |
# File 'app/models/decidim/budgets/project.rb', line 107 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.
90 91 92 |
# File 'app/models/decidim/budgets/project.rb', line 90 def users_to_notify_on_comment_created followers end |