Sha256: 3a6765f162f7c66ec766e4941d9b4a5c28477d5cbfc12f64e51f1a1825d86fca

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Decidim
  module Blogs
    # 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 Post < Blogs::ApplicationRecord
      include Decidim::Resourceable
      include Decidim::HasComponent
      include Decidim::Authorable
      include Decidim::Comments::Commentable
      include Traceable
      include Loggable

      component_manifest_name "blogs"

      validates :title, presence: true

      scope :created_at_desc, -> { order(arel_table[:created_at].desc) }

      # Public: Overrides the `commentable?` Commentable concern method.
      def commentable?
        component.settings.comments_enabled?
      end

      # Public: Overrides the `accepts_new_comments?` Commentable concern method.
      def accepts_new_comments?
        commentable? && !component.current_settings.comments_blocked
      end

      # Public: Overrides the `comments_have_alignment?` Commentable concern method.
      def comments_have_alignment?
        true
      end

      # Public: Overrides the `comments_have_votes?` Commentable concern method.
      def comments_have_votes?
        true
      end

      def official?
        author.nil?
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-blogs-0.17.2 app/models/decidim/blogs/post.rb
decidim-blogs-0.17.1 app/models/decidim/blogs/post.rb
decidim-blogs-0.16.1 app/models/decidim/blogs/post.rb
decidim-blogs-0.17.0 app/models/decidim/blogs/post.rb
decidim-blogs-0.16.0 app/models/decidim/blogs/post.rb
decidim-blogs-0.15.2 app/models/decidim/blogs/post.rb
decidim-blogs-0.15.1 app/models/decidim/blogs/post.rb
decidim-blogs-0.15.0 app/models/decidim/blogs/post.rb