Class: Decidim::Dev::DummyResource

Inherits:
ApplicationRecord show all
Includes:
Amendable, Authorable, Comments::Commentable, Decidim::DownloadYourData, Endorsable, HasAttachments, NewsletterParticipant, ShareableWithToken, TranslatableResource, Followable, HasCategory, HasComponent, HasReference, Paddable, Publicable, Reportable, Resourceable, ScopableResource, Searchable, Traceable
Defined in:
app/models/decidim/dev/dummy_resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.export_serializerObject



80
81
82
# File 'app/models/decidim/dev/dummy_resource.rb', line 80

def self.export_serializer
  DummySerializer
end

.newsletter_participant_ids(component) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'app/models/decidim/dev/dummy_resource.rb', line 84

def self.newsletter_participant_ids(component)
  authors_ids = 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:))
  (authors_ids + commentators_ids).flatten.compact.uniq
end

.user_collection(user) ⇒ Object



76
77
78
# File 'app/models/decidim/dev/dummy_resource.rb', line 76

def self.user_collection(user)
  where(decidim_author_id: user.id, decidim_author_type: "Decidim::User")
end

Instance Method Details

#allow_resource_permissions?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/models/decidim/dev/dummy_resource.rb', line 55

def allow_resource_permissions?
  component.settings.resources_permissions_enabled
end

#commentable?Boolean

Public: Overrides the ‘commentable?` Commentable concern method.

Returns:

  • (Boolean)


60
61
62
# File 'app/models/decidim/dev/dummy_resource.rb', line 60

def commentable?
  component.settings.comments_enabled?
end

#reported_attributesObject



47
48
49
# File 'app/models/decidim/dev/dummy_resource.rb', line 47

def reported_attributes
  [:title]
end

#reported_content_urlObject



43
44
45
# File 'app/models/decidim/dev/dummy_resource.rb', line 43

def reported_content_url
  ResourceLocatorPresenter.new(self).url
end

#reported_searchable_content_extrasObject



51
52
53
# File 'app/models/decidim/dev/dummy_resource.rb', line 51

def reported_searchable_content_extras
  [normalized_author.name]
end

#user_allowed_to_comment?(user) ⇒ Boolean

Public: Whether the object can have new comments or not.

Returns:

  • (Boolean)


65
66
67
68
69
# File 'app/models/decidim/dev/dummy_resource.rb', line 65

def user_allowed_to_comment?(user)
  return unless component.can_participate_in_space?(user)

  ActionAuthorizer.new(user, "comment", component, self).authorize.ok?
end

#user_allowed_to_vote_comment?(user) ⇒ Boolean

Public: Whether the object can have new comment votes or not.

Returns:

  • (Boolean)


72
73
74
# File 'app/models/decidim/dev/dummy_resource.rb', line 72

def user_allowed_to_vote_comment?(user)
  component.can_participate_in_space?(user)
end