Class: Decidim::Blogs::BlogsType
- Inherits:
-
Api::Types::BaseObject
- Object
- Api::Types::BaseObject
- Decidim::Blogs::BlogsType
- Defined in:
- lib/decidim/api/blogs_type.rb
Instance Method Summary collapse
Instance Method Details
#post(id:) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/decidim/api/blogs_type.rb', line 29 def post(id:) scope = if context[:current_user]&.admin? Post else Post.published end Decidim::Core::ComponentFinderBase.new(model_class: scope).call(object, { id: }, context) end |
#posts(filter: {}, order: {}) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/decidim/api/blogs_type.rb', line 20 def posts(filter: {}, order: {}) base_query = Decidim::Core::ComponentListBase.new(model_class: Post).call(object, { filter:, order: }, context) if context[:current_user]&.admin? base_query else base_query.published end end |