Class: Decidim::Blogs::Post
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Blogs::Post
- 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
-
#allow_resource_permissions? ⇒ Boolean
Public: Overrides the ‘allow_resource_permissions?` Resourceable concern method.
- #attachment_context ⇒ Object
-
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
-
#comments_have_votes? ⇒ Boolean
Public: Overrides the ‘comments_have_votes?` Commentable concern method.
- #official? ⇒ Boolean
-
#presenter ⇒ Object
Returns the presenter for this BlogPost, to be used in the views.
- #published? ⇒ Boolean
-
#reported_attributes ⇒ Object
Public: Overrides the ‘reported_attributes` Reportable concern method.
-
#reported_searchable_content_extras ⇒ Object
Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.
- #users_to_notify_on_comment_created ⇒ Object
- #visible? ⇒ Boolean
Class Method Details
.all_timestamp_attributes_in_model ⇒ Object
45 46 47 |
# File 'app/models/decidim/blogs/post.rb', line 45 def 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.
79 80 81 |
# File 'app/models/decidim/blogs/post.rb', line 79 def true end |
#attachment_context ⇒ Object
91 92 93 |
# File 'app/models/decidim/blogs/post.rb', line 91 def :admin end |
#comments_have_alignment? ⇒ Boolean
Public: Overrides the ‘comments_have_alignment?` Commentable concern method.
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.
74 75 76 |
# File 'app/models/decidim/blogs/post.rb', line 74 def comments_have_votes? true end |
#official? ⇒ Boolean
83 84 85 |
# File 'app/models/decidim/blogs/post.rb', line 83 def official? .is_a?(Decidim::Organization) end |
#presenter ⇒ Object
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
64 65 66 |
# File 'app/models/decidim/blogs/post.rb', line 64 def published? super && published_at <= Time.current end |
#reported_attributes ⇒ Object
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_extras ⇒ Object
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 [.name] end |
#users_to_notify_on_comment_created ⇒ Object
87 88 89 |
# File 'app/models/decidim/blogs/post.rb', line 87 def users_to_notify_on_comment_created followers end |
#visible? ⇒ Boolean
60 61 62 |
# File 'app/models/decidim/blogs/post.rb', line 60 def visible? participatory_space.try(:visible?) && component.try(:published?) && published? end |