Class: Decidim::Dev::DummyResource
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Dev::DummyResource
- Includes:
- Amendable, Authorable, Comments::Commentable, Decidim::DownloadYourData, Endorsable, Followable, HasAttachments, HasCategory, HasComponent, HasReference, NewsletterParticipant, Paddable, Publicable, Reportable, Resourceable, ScopableResource, Searchable, ShareableWithToken, SoftDeletable, Taxonomizable, Traceable, TranslatableResource
- Defined in:
- decidim-dev/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
-
#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.
Methods included from HasAttachments
Methods included from Amendable
#add_author, #amendable?, #amendable_fields, #amendable_form, #amendment, #emendation?, #linked_promoted_resource, #notifiable_identities, #process_amendment_state_change!, #state, #visible_amendments_for, #visible_emendations_for
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 Publicable
#previously_published?, #publish!, #published?, #unpublish!
Methods included from Followable
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Class Method Details
.export_serializer ⇒ Object
82 83 84 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 82 def self.export_serializer DummySerializer end |
.newsletter_participant_ids(component) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 86 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
78 79 80 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 78 def self.user_collection(user) where(decidim_author_id: user.id, decidim_author_type: "Decidim::User") end |
Instance Method Details
#allow_resource_permissions? ⇒ Boolean
57 58 59 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 57 def component.settings. end |
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
62 63 64 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 62 def commentable? component.settings.comments_enabled? end |
#presenter ⇒ Object
45 46 47 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 45 def presenter Decidim::Dev::DummyResourcePresenter.new(self) end |
#reported_attributes ⇒ Object
49 50 51 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 49 def reported_attributes [:title] end |
#reported_searchable_content_extras ⇒ Object
53 54 55 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 53 def reported_searchable_content_extras [.name] end |
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
67 68 69 70 71 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 67 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.
74 75 76 |
# File 'decidim-dev/app/models/decidim/dev/dummy_resource.rb', line 74 def user_allowed_to_vote_comment?(user) component.can_participate_in_space?(user) end |