Class: Decidim::Blogs::Post

Inherits:
ApplicationRecord show all
Includes:
Authorable, Comments::CommentableWithComponent, Endorsable, Followable, HasAttachmentCollections, HasAttachments, HasComponent, Reportable, Resourceable, Searchable, TranslatableResource, Loggable, Traceable
Defined in:
app/models/decidim/blogs/post.rb

Overview

The data store for a Blog in the Decidim::Blogs component. It stores a title, description and any other useful information to render a blog.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log_presenter_class_for(_log) ⇒ Object



43
44
45
# File 'app/models/decidim/blogs/post.rb', line 43

def self.log_presenter_class_for(_log)
  Decidim::Blogs::AdminLog::PostPresenter
end

Instance Method Details

#allow_resource_permissions?Boolean

Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.

Returns:

  • (Boolean)


58
59
60
# File 'app/models/decidim/blogs/post.rb', line 58

def allow_resource_permissions?
  true
end

#attachment_contextObject



74
75
76
# File 'app/models/decidim/blogs/post.rb', line 74

def attachment_context
  :admin
end

#comments_have_alignment?Boolean

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

Returns:

  • (Boolean)


48
49
50
# File 'app/models/decidim/blogs/post.rb', line 48

def comments_have_alignment?
  true
end

#comments_have_votes?Boolean

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

Returns:

  • (Boolean)


53
54
55
# File 'app/models/decidim/blogs/post.rb', line 53

def comments_have_votes?
  true
end

#official?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/decidim/blogs/post.rb', line 62

def official?
  author.is_a?(Decidim::Organization)
end

#reported_attributesObject

Public: Overrides the ‘reported_attributes` Reportable concern method.



84
85
86
# File 'app/models/decidim/blogs/post.rb', line 84

def reported_attributes
  [:title, :body]
end

#reported_content_urlObject

Public: Overrides the ‘reported_content_url` Reportable concern method.



79
80
81
# File 'app/models/decidim/blogs/post.rb', line 79

def reported_content_url
  ResourceLocatorPresenter.new(self).url
end

#reported_searchable_content_extrasObject

Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.



89
90
91
# File 'app/models/decidim/blogs/post.rb', line 89

def reported_searchable_content_extras
  [normalized_author.name]
end

#user_group?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/models/decidim/blogs/post.rb', line 66

def user_group?
  author.is_a?(Decidim::UserGroup)
end

#users_to_notify_on_comment_createdObject



70
71
72
# File 'app/models/decidim/blogs/post.rb', line 70

def users_to_notify_on_comment_created
  followers
end

#visible?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/decidim/blogs/post.rb', line 39

def visible?
  participatory_space.try(:visible?) && component.try(:published?)
end