Class: Decidim::Blogs::BlogsType
Instance Method Summary
collapse
authorized?
allowed_to?, authorized?, determine_subject_name, local_context, permission_chain
Instance Method Details
#post(id:) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'decidim-blogs/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 'decidim-blogs/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
|