Skip to content

Commit

Permalink
WIP add new page relation that does not include deprecated elements
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Jan 15, 2021
1 parent 7293d18 commit 2670cdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/alchemy/json_api/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def jsonapi_meta(pages)

{
pagination: pagination.presence,
total: page_scope.count
total: page_scope.count,
}.compact
end

Expand All @@ -48,7 +48,7 @@ def page_scope
def page_scope_with_includes
base_page_scope.
with_language(Language.current).
preload(language: {nodes: [:parent, :page]}, all_elements: [:parent_element, :nested_elements, { contents: { essence: :ingredient_association } }])
includes(language: { nodes: [:parent, :page] }, all_elements: [:parent_element, :nested_elements, { contents: { essence: :ingredient_association } }])
end

def base_page_scope
Expand Down
4 changes: 4 additions & 0 deletions app/serializers/alchemy/json_api/page_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class PageSerializer
page.all_elements.select { |e| e.public? && !e.trashed? }
end

has_many :all_non_deprecated_elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |page|
page.all_elements.select { |e| e.public? && !e.trashed? && !e.deprecated? }
end

with_options if: ->(_, params) { params[:admin] == true } do
attribute :tag_list
attribute :status
Expand Down

0 comments on commit 2670cdf

Please sign in to comment.