Class: Decidim::Dev::DummyResource
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Dev::DummyResource
- Includes:
- Amendable, Authorable, Comments::Commentable, Decidim::DownloadYourData, HasAttachments, Likeable, NewsletterParticipant, ShareableWithToken, SoftDeletable, TranslatableResource, Followable, HasCategory, HasComponent, HasReference, Paddable, Publicable, Reportable, Resourceable, ScopableResource, Searchable, Taxonomizable, Traceable
- Defined in:
- app/models/decidim/dev/dummy_resource.rb
Class Method Summary collapse
- .export_serializer ⇒ Object
- .newsletter_participant_ids(component) ⇒ Object
- .user_collection(user) ⇒ Object
Instance Method Summary collapse
- #allow_resource_permissions? ⇒ Boolean
- #authors ⇒ Object
-
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
- #presenter ⇒ Object
- #reported_attributes ⇒ Object
- #reported_searchable_content_extras ⇒ Object
-
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
-
#user_allowed_to_vote_comment?(user) ⇒ Boolean
Public: Whether the object can have new comment votes or not.
Class Method Details
.export_serializer ⇒ Object
88 89 90 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 88 def self.export_serializer DummySerializer end |
.newsletter_participant_ids(component) ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 92 def self.(component) = Decidim::Dev::DummyResource.where(component:) .where(decidim_author_type: Decidim::UserBaseEntity.name) .where.not(author: nil) .group(:decidim_author_id) .pluck(:decidim_author_id) commentators_ids = Decidim::Comments::Comment.user_commentators_ids_in(Decidim::Dev::DummyResource.where(component:)) ( + commentators_ids).flatten.compact.uniq end |
.user_collection(user) ⇒ Object
84 85 86 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 84 def self.user_collection(user) where(decidim_author_id: user.id, decidim_author_type: "Decidim::User") end |
Instance Method Details
#allow_resource_permissions? ⇒ Boolean
63 64 65 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 63 def component.settings. end |
#authors ⇒ Object
47 48 49 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 47 def [] end |
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
68 69 70 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 68 def commentable? component.settings.comments_enabled? end |
#presenter ⇒ Object
51 52 53 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 51 def presenter Decidim::Dev::DummyResourcePresenter.new(self) end |
#reported_attributes ⇒ Object
55 56 57 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 55 def reported_attributes [:title] end |
#reported_searchable_content_extras ⇒ Object
59 60 61 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 59 def reported_searchable_content_extras [.name] end |
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
73 74 75 76 77 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 73 def user_allowed_to_comment?(user) return unless component.can_participate_in_space?(user) ActionAuthorizer.new(user, "comment", component, self)..ok? end |
#user_allowed_to_vote_comment?(user) ⇒ Boolean
Public: Whether the object can have new comment votes or not.
80 81 82 |
# File 'app/models/decidim/dev/dummy_resource.rb', line 80 def user_allowed_to_vote_comment?(user) component.can_participate_in_space?(user) end |