Class: Decidim::Blogs::Post

Inherits:
ApplicationRecord show all
Includes:
Authorable, Comments::CommentableWithComponent, 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.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Followable

#followers

Class Method Details

.all_timestamp_attributes_in_modelObject


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

def all_timestamp_attributes_in_model
  super + ["published_at"]
end

.log_presenter_class_for(_log) ⇒ Object


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

def 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)

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

def allow_resource_permissions?
  true
end

#attachment_contextObject


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

def attachment_context
  :admin
end

#comments_have_alignment?Boolean

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

Returns:

  • (Boolean)

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

def comments_have_alignment?
  true
end

#comments_have_votes?Boolean

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

Returns:

  • (Boolean)

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

def comments_have_votes?
  true
end

#official?Boolean

Returns:

  • (Boolean)

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

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

#published?Boolean

Returns:

  • (Boolean)

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

def published?
  published_at <= Time.current
end

#user_group?Boolean

Returns:

  • (Boolean)

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

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

#users_to_notify_on_comment_createdObject


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

def users_to_notify_on_comment_created
  followers
end

#visible?Boolean

Returns:

  • (Boolean)

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

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