forest_liana 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/forest_liana/application_controller.rb +19 -0
- data/app/models/forest_liana/model/action.rb +2 -1
- data/app/serializers/forest_liana/action_serializer.rb +1 -0
- data/app/services/forest_liana/search_query_builder.rb +6 -1
- data/lib/forest_liana/collection.rb +15 -0
- data/lib/forest_liana/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca3cd85fa0dc894ada98152c54ff3184775a9b51
|
4
|
+
data.tar.gz: 9d1dabf5ae603b209ee00f46e508db1c1a2ad9d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 980aefac21934ff1e8a6557d7943ada0a4f33e2b12e3058cde3b2101565802af29ba97decaf9fb02b9331175af24678332e666e22baaa7b7f1913ef38309ff81
|
7
|
+
data.tar.gz: 71a080e9c7e7db63302097f78127a590ea16d70d580b25588c78ac3e37c49d5bdcdb775eaa18d3f5e5e7fcd07682208fc1b58174c22ea739edbf5a6b04444d09
|
@@ -2,14 +2,33 @@ require 'jwt'
|
|
2
2
|
|
3
3
|
module ForestLiana
|
4
4
|
class ApplicationController < ::ActionController::Base
|
5
|
+
|
6
|
+
def self.papertrail?
|
7
|
+
Object.const_get('PaperTrail::Version').is_a?(Class) rescue false
|
8
|
+
end
|
9
|
+
|
10
|
+
# NOTICE: Calling the method set_paper_trail_whodunnit loads the PaperTrail
|
11
|
+
# gem and Forest detects the PaperTrail::Version automatically. This
|
12
|
+
# method is used to set the whodunnit field automatically to track
|
13
|
+
# changes made using Forest with PaperTrail.
|
5
14
|
if Rails::VERSION::MAJOR < 4
|
6
15
|
before_filter :authenticate_user_from_jwt
|
16
|
+
before_filter :set_paper_trail_whodunnit if self.papertrail?
|
7
17
|
else
|
8
18
|
before_action :authenticate_user_from_jwt
|
19
|
+
before_action :set_paper_trail_whodunnit if self.papertrail?
|
9
20
|
end
|
10
21
|
|
11
22
|
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
12
23
|
|
24
|
+
if self.papertrail?
|
25
|
+
# NOTICE: The Forest user email is returned to track changes made using
|
26
|
+
# Forest with Papertrail.
|
27
|
+
define_method :user_for_paper_trail do
|
28
|
+
forest_user.dig('data', 'data', 'email')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
13
32
|
def forest_user
|
14
33
|
@jwt_decoded_token
|
15
34
|
end
|
@@ -4,7 +4,8 @@ class ForestLiana::Model::Action
|
|
4
4
|
include ActiveModel::Serialization
|
5
5
|
extend ActiveModel::Naming
|
6
6
|
|
7
|
-
attr_accessor :id, :name, :endpoint, :http_method, :fields, :redirect,
|
7
|
+
attr_accessor :id, :name, :endpoint, :http_method, :fields, :redirect,
|
8
|
+
:global, :download
|
8
9
|
|
9
10
|
def initialize(attributes = {})
|
10
11
|
attributes.each do |name, value|
|
@@ -17,7 +17,12 @@ module ForestLiana
|
|
17
17
|
if @params[:search]
|
18
18
|
ForestLiana.schema_for_resource(@resource).fields.each do |field|
|
19
19
|
if field.try(:[], :search)
|
20
|
-
|
20
|
+
begin
|
21
|
+
@records = field[:search].call(@records, @params[:search])
|
22
|
+
rescue => exception
|
23
|
+
FOREST_LOGGER.error "Cannot search properly on Smart Field :\n" \
|
24
|
+
"#{exception}"
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -62,6 +62,21 @@ module ForestLiana::Collection
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
def belongs_to(name, opts, &block)
|
66
|
+
model.fields << opts.merge({
|
67
|
+
field: name,
|
68
|
+
:'is-searchable' => false,
|
69
|
+
type: 'String'
|
70
|
+
})
|
71
|
+
|
72
|
+
if serializer_name && ForestLiana::UserSpace.const_defined?(
|
73
|
+
serializer_name)
|
74
|
+
ForestLiana::UserSpace.const_get(serializer_name).class_eval do
|
75
|
+
has_one(name, name: name, include_data: true, &block)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
65
80
|
private
|
66
81
|
|
67
82
|
def model
|
data/lib/forest_liana/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_liana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|