Class: Decidim::Blogs::Post

Inherits:
ApplicationRecord show all
Includes:
Authorable, Comments::Commentable, Endorsable, Followable, HasAttachmentCollections, HasAttachments, HasComponent, Loggable, Resourceable, Searchable, Traceable, TranslatableResource
Defined in:
decidim-blogs/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.

Instance Method Summary collapse

Methods included from Followable

#followers

Methods included from Searchable

searchable_resources, searchable_resources_of_type_comment, searchable_resources_of_type_component, searchable_resources_of_type_participant, searchable_resources_of_type_participatory_space

Instance Method Details

#accepts_new_comments?Boolean

Public: Overrides the `accepts_new_comments?` Commentable concern method.

Returns:

  • (Boolean)

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

def accepts_new_comments?
  commentable? && !component.current_settings.comments_blocked
end

#attachment_contextObject


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

def attachment_context
  :admin
end

#commentable?Boolean

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

Returns:

  • (Boolean)

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

def commentable?
  component.settings.comments_enabled?
end

#comments_have_alignment?Boolean

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

Returns:

  • (Boolean)

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

def comments_have_alignment?
  true
end

#comments_have_votes?Boolean

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

Returns:

  • (Boolean)

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

def comments_have_votes?
  true
end

#official?Boolean

Returns:

  • (Boolean)

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

def official?
  author.nil?
end

#user_allowed_to_comment?(user) ⇒ Boolean

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

Returns:

  • (Boolean)

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

def user_allowed_to_comment?(user)
  can_participate_in_space?(user)
end

#users_to_notify_on_comment_createdObject


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

def users_to_notify_on_comment_created
  followers
end

#visible?Boolean

Returns:

  • (Boolean)

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

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