Class: Decidim::Blogs::Post

Inherits:
ApplicationRecord show all
Includes:
Authorable, Comments::CommentableWithComponent, Followable, HasAttachmentCollections, HasAttachments, HasComponent, Likeable, Publicable, Reportable, Resourceable, Searchable, SoftDeletable, Taxonomizable, 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

.all_timestamp_attributes_in_modelObject



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

def all_timestamp_attributes_in_model
  super + ["published_at"]
end

.log_presenter_class_for(_log) ⇒ Object



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

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)


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

def allow_resource_permissions?
  true
end

#attachment_contextObject



91
92
93
# File 'app/models/decidim/blogs/post.rb', line 91

def attachment_context
  :admin
end

#comments_have_alignment?Boolean

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

Returns:

  • (Boolean)


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

def comments_have_alignment?
  true
end

#comments_have_votes?Boolean

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

Returns:

  • (Boolean)


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

def comments_have_votes?
  true
end

#official?Boolean

Returns:

  • (Boolean)


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

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

#presenterObject

Returns the presenter for this BlogPost, to be used in the views. Required by ResourceRenderer.



56
57
58
# File 'app/models/decidim/blogs/post.rb', line 56

def presenter
  Decidim::Blogs::PostPresenter.new(self)
end

#published?Boolean

Returns:

  • (Boolean)


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

def published?
  super && published_at <= Time.current
end

#reported_attributesObject

Public: Overrides the ‘reported_attributes` Reportable concern method.



96
97
98
# File 'app/models/decidim/blogs/post.rb', line 96

def reported_attributes
  [:title, :body]
end

#reported_searchable_content_extrasObject

Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.



101
102
103
# File 'app/models/decidim/blogs/post.rb', line 101

def reported_searchable_content_extras
  [author.name]
end

#users_to_notify_on_comment_createdObject



87
88
89
# File 'app/models/decidim/blogs/post.rb', line 87

def users_to_notify_on_comment_created
  followers
end

#visible?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/models/decidim/blogs/post.rb', line 60

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