forest_liana 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 104691fcb178a8fdea75c0db24ecfc886a8a5478
4
- data.tar.gz: 93b61ee994b34e70e22da8de9a5b30eda88bc8ac
3
+ metadata.gz: ca3cd85fa0dc894ada98152c54ff3184775a9b51
4
+ data.tar.gz: 9d1dabf5ae603b209ee00f46e508db1c1a2ad9d1
5
5
  SHA512:
6
- metadata.gz: b1112819867ebcedb6cd48ed4590b48e940ef01bcd70925af506b10ebda618780fdd579db4ea6be3ee914ba896926d68edd00a515ec009a0b6c1b1afc78e2509
7
- data.tar.gz: 7c5af3e6a8b13091fe7b35cdc1c6ac3a725cde71bf6402ca64ca3dd476de7622450e0946d4c0b5c737c4d45771ddbf6427c89fe44dc8aa844fcc752b0be831dd
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, :global
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|
@@ -9,6 +9,7 @@ class ForestLiana::ActionSerializer
9
9
  attribute :fields
10
10
  attribute :redirect
11
11
  attribute :global
12
+ attribute :download
12
13
 
13
14
  def relationship_related_link(attribute_name)
14
15
  nil
@@ -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
- @records = field[:search].call(@records, @params[:search])
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
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.6.1"
2
+ VERSION = "1.6.2"
3
3
  end
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.1
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-26 00:00:00.000000000 Z
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails