alchemy-json_api 0.8.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d820e87bf877fa770b6145ca3e2e50b907bb673d917a416723ad13b3edb72158
4
- data.tar.gz: 907f95e93d6bbe7bcd57e64b768d86ad459dd7fb5fd957692e16eaf251369be0
3
+ metadata.gz: 566f8ea63b33d368120cc948fa2c61b4b0039957249e85718f650e8e7ca8d322
4
+ data.tar.gz: 6816b1a2b645b9711a77bd8916814cd245b319e8144c6de278ec3f780c03f36f
5
5
  SHA512:
6
- metadata.gz: c1119df682cb6a9cb82447da59a3f24afc59c7dad9fb44c65dd8a16dbfdc74826ebab74d65e2b697e2fc7117519d71d8dafc149b71f035f32b7da4be02edce03
7
- data.tar.gz: 0d83f06aa5aeeaf44712096197324bab31be452196d795504ee2ec0b3d34006de68b41ce20c3ad6a2fff84251d13184a953d165b7cf06b32b9c9df7849f5d24d
6
+ metadata.gz: 6041f03d5b9264d25312b7e4e1e50d9e5aae32154a47d8e8178bf7ab1dbd5362127e683d40ecba95f1fd05bb1d503afb6444286a97e99bcf5514fa4d48ade95c
7
+ data.tar.gz: 5355f10ab5dc5ae2ff7b2fb9412358467e4d351c23efbb37e8a9fbe6e300e6848d6e2b3a01c58fae8d1fbf8df00749835d55b65c43b2705dfcf2431281ef6a8a
@@ -4,8 +4,12 @@ module Alchemy
4
4
  class LayoutPagesController < JsonApi::PagesController
5
5
  private
6
6
 
7
+ def base_page_scope
8
+ Page.all
9
+ end
10
+
7
11
  def page_scope
8
- base_page_scope.layoutpages
12
+ page_scope_with_includes.layoutpages
9
13
  end
10
14
  end
11
15
  end
@@ -42,19 +42,22 @@ module Alchemy
42
42
  end
43
43
 
44
44
  def page_scope
45
- base_page_scope.contentpages
45
+ page_scope_with_includes.contentpages
46
+ end
47
+
48
+ def page_scope_with_includes
49
+ base_page_scope.
50
+ with_language(Language.current).
51
+ preload(language: {nodes: [:parent, :page]}, all_elements: [:parent_element, :nested_elements, { contents: { essence: :ingredient_association } }])
46
52
  end
47
53
 
48
54
  def base_page_scope
49
55
  # cancancan is not able to merge our complex AR scopes for logged in users
50
56
  if can?(:edit_content, Page)
51
- pages = Page.all
57
+ Page.all
52
58
  else
53
- pages = Page.accessible_by(current_ability, :index)
59
+ Page.published
54
60
  end
55
- pages.
56
- with_language(Language.current).
57
- preload(language: {nodes: [:parent, :page]}, all_elements: [:parent_element, :nested_elements, { contents: { essence: :ingredient_association } }])
58
61
  end
59
62
 
60
63
  def jsonapi_serializer_class(_resource, _is_collection)
@@ -2,7 +2,8 @@
2
2
  module Alchemy
3
3
  module JsonApi
4
4
  class ElementSerializer
5
- include FastJsonapi::ObjectSerializer
5
+ include JSONAPI::Serializer
6
+
6
7
  attributes(
7
8
  :name,
8
9
  :fixed,
@@ -15,10 +16,12 @@ module Alchemy
15
16
  belongs_to :page, record_type: :page, serializer: ::Alchemy::JsonApi::PageSerializer
16
17
 
17
18
  has_many :essences, polymorphic: true do |element|
18
- element.contents.map(&:essence)
19
+ element.contents.reject { |c| !!c.try(:deprecated?) }.map!(&:essence)
19
20
  end
20
21
 
21
- has_many :nested_elements, record_type: :element, serializer: self
22
+ has_many :nested_elements, record_type: :element, serializer: self do |element|
23
+ element.nested_elements.reject { |c| !!c.try(:deprecated?) }
24
+ end
22
25
 
23
26
  with_options if: ->(_, params) { params[:admin] == true } do
24
27
  attribute :tag_list
@@ -2,7 +2,8 @@
2
2
  module Alchemy
3
3
  module JsonApi
4
4
  class LanguageSerializer
5
- include FastJsonapi::ObjectSerializer
5
+ include JSONAPI::Serializer
6
+
6
7
  attributes(
7
8
  :name,
8
9
  :language_code,
@@ -2,7 +2,7 @@
2
2
  module Alchemy
3
3
  module JsonApi
4
4
  class NodeSerializer
5
- include FastJsonapi::ObjectSerializer
5
+ include JSONAPI::Serializer
6
6
 
7
7
  attributes :name
8
8
  attribute :link_url, &:url
@@ -2,7 +2,8 @@
2
2
  module Alchemy
3
3
  module JsonApi
4
4
  class PageSerializer
5
- include FastJsonapi::ObjectSerializer
5
+ include JSONAPI::Serializer
6
+
6
7
  attributes(
7
8
  :name,
8
9
  :urlname,
@@ -17,11 +18,16 @@ module Alchemy
17
18
 
18
19
  belongs_to :language, record_type: :language, serializer: ::Alchemy::JsonApi::LanguageSerializer
19
20
 
20
- has_many :elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer
21
- has_many :fixed_elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer
21
+ has_many :elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |page|
22
+ page.elements.reject { |e| !!e.try(:deprecated?) }
23
+ end
24
+
25
+ has_many :fixed_elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |page|
26
+ page.fixed_elements.reject { |c| !!c.try(:deprecated?) }
27
+ end
22
28
 
23
29
  has_many :all_elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |page|
24
- page.all_elements.select { |e| e.public? && !e.trashed? }
30
+ page.all_elements.select { |e| e.public? && !e.trashed? && !e.try(:deprecated?) }
25
31
  end
26
32
 
27
33
  with_options if: ->(_, params) { params[:admin] == true } do
@@ -3,7 +3,7 @@ module Alchemy
3
3
  module JsonApi
4
4
  module EssenceSerializer
5
5
  def self.included(klass)
6
- klass.include FastJsonapi::ObjectSerializer
6
+ klass.include JSONAPI::Serializer
7
7
  klass.has_one :element, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |essence|
8
8
  essence.content.element
9
9
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Alchemy
3
3
  module JsonApi
4
- VERSION = "0.8.0"
4
+ VERSION = "0.10.1"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,57 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-json_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2021-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '5.0'
27
- - !ruby/object:Gem::Dependency
28
- name: fast_jsonapi
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
30
+ - - "<"
32
31
  - !ruby/object:Gem::Version
33
- version: '1.5'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.5'
32
+ version: '6.1'
41
33
  - !ruby/object:Gem::Dependency
42
34
  name: jsonapi.rb
43
35
  requirement: !ruby/object:Gem::Requirement
44
36
  requirements:
45
- - - ">="
37
+ - - "~>"
46
38
  - !ruby/object:Gem::Version
47
- version: '0'
39
+ version: '1.6'
48
40
  type: :runtime
49
41
  prerelease: false
50
42
  version_requirements: !ruby/object:Gem::Requirement
51
43
  requirements:
52
- - - ">="
44
+ - - "~>"
53
45
  - !ruby/object:Gem::Version
54
- version: '0'
46
+ version: '1.6'
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: factory_bot
57
49
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +139,7 @@ homepage: https://github.com/AlchemyCMS/alchemy-json_api
147
139
  licenses:
148
140
  - MIT
149
141
  metadata: {}
150
- post_install_message:
142
+ post_install_message:
151
143
  rdoc_options: []
152
144
  require_paths:
153
145
  - lib
@@ -163,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
155
  version: '0'
164
156
  requirements: []
165
157
  rubygems_version: 3.1.4
166
- signing_key:
158
+ signing_key:
167
159
  specification_version: 4
168
160
  summary: A JSONAPI compliant API for AlchemyCMS
169
161
  test_files: []