Class: Decidim::Blogs::BlogsType
- Inherits:
-
Core::ComponentType
- Object
- Core::ComponentType
- Decidim::Blogs::BlogsType
- Defined in:
- lib/decidim/api/blogs_type.rb
Instance Method Summary collapse
Instance Method Details
#post(id:) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/decidim/api/blogs_type.rb', line 26 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
17 18 19 20 21 22 23 24 |
# File 'lib/decidim/api/blogs_type.rb', line 17 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 |