rails_admin 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails_admin might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 304c4e0f0cb8e46bab128045cd480163e9b86e6e
|
4
|
+
data.tar.gz: e3a2a9e2c86f2227c0b8b9b3cdf955b4695154dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d489cc488adace10d7645b530f303e81cf96f981fddda20a01b9ff93e3b36678b23fe1ddd277d99a606c3ddec57c61851ebbace6d2e1515d7f36db97b49153a
|
7
|
+
data.tar.gz: 7bfe657ca2eb9c41646736d33985adcc02fb1184689e0f69320f4a9fc838c15fb139f43872570be8752021a9387a077bd87d88acbd39458c9df027250a7cdd77
|
data/lib/rails_admin/engine.rb
CHANGED
@@ -43,7 +43,8 @@ module RailsAdmin
|
|
43
43
|
Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
# Check for required middlewares, can be missing in Rails API mode
|
47
|
+
config.after_initialize do |app|
|
47
48
|
has_session_store = app.config.middleware.to_a.any? { |m| m.klass.try(:<=, ActionDispatch::Session::AbstractStore) } || ::Rails.version < '5.0'
|
48
49
|
loaded = app.config.middleware.to_a.map(&:name)
|
49
50
|
required = %w(ActionDispatch::Cookies ActionDispatch::Flash Rack::MethodOverride)
|
@@ -37,6 +37,16 @@ module RailsAdmin
|
|
37
37
|
created_at: :created_at,
|
38
38
|
message: :event,
|
39
39
|
}.freeze
|
40
|
+
E_VERSION_MODEL_NOT_SET = <<-EOS.strip_heredoc.freeze
|
41
|
+
Please set up PaperTrail's version model explicitly.
|
42
|
+
|
43
|
+
config.audit_with :paper_trail, 'User', 'PaperTrail::Version'
|
44
|
+
|
45
|
+
If you have configured a model to use a custom version class
|
46
|
+
(https://github.com/paper-trail-gem/paper_trail#6a-custom-version-classes)
|
47
|
+
that configuration will take precedence over what you specify in
|
48
|
+
`audit_with`.
|
49
|
+
EOS
|
40
50
|
|
41
51
|
def self.setup
|
42
52
|
raise('PaperTrail not found') unless defined?(::PaperTrail)
|
@@ -59,7 +69,7 @@ module RailsAdmin
|
|
59
69
|
begin
|
60
70
|
@version_class = version_class.to_s.constantize
|
61
71
|
rescue NameError
|
62
|
-
raise
|
72
|
+
raise E_VERSION_MODEL_NOT_SET
|
63
73
|
end
|
64
74
|
end
|
65
75
|
|
@@ -91,6 +101,7 @@ module RailsAdmin
|
|
91
101
|
|
92
102
|
protected
|
93
103
|
|
104
|
+
# - model - a RailsAdmin::AbstractModel
|
94
105
|
def listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page)
|
95
106
|
if sort.present?
|
96
107
|
sort = COLUMN_MAPPING[sort.to_sym]
|
@@ -99,11 +110,10 @@ module RailsAdmin
|
|
99
110
|
sort_reverse = 'true'
|
100
111
|
end
|
101
112
|
|
102
|
-
|
103
|
-
|
113
|
+
ar_model = model.model
|
104
114
|
current_page = page.presence || '1'
|
105
115
|
|
106
|
-
versions = version_class_for(
|
116
|
+
versions = version_class_for(ar_model).where item_type: ar_model.name
|
107
117
|
versions = versions.where item_id: object.id if object
|
108
118
|
versions = versions.where('event LIKE ?', "%#{query}%") if query.present?
|
109
119
|
versions = versions.order(sort_reverse == 'true' ? "#{sort} DESC" : sort)
|
@@ -116,12 +126,14 @@ module RailsAdmin
|
|
116
126
|
paginated_proxies
|
117
127
|
end
|
118
128
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
129
|
+
# PT can be configured to use [custom version
|
130
|
+
# classes](https://github.com/paper-trail-gem/paper_trail#6a-custom-version-classes)
|
131
|
+
#
|
132
|
+
# ```ruby
|
133
|
+
# has_paper_trail class_name: 'MyVersion'
|
134
|
+
# ```
|
135
|
+
def version_class_for(model)
|
136
|
+
model.paper_trail_options[:class_name].try(:constantize) || @version_class
|
125
137
|
end
|
126
138
|
end
|
127
139
|
end
|
data/lib/rails_admin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Michaels-Ober
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2018-
|
15
|
+
date: 2018-09-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: builder
|