effective_logging 4.1.2 → 4.2.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd43bfe19f220a08425b7f93f3160ef4d2fa4107e6eb8c7d00d7e92dff2ede90
|
4
|
+
data.tar.gz: 3d0a977bcff9579e325523aa03472b107d028f2076197e947913b6b4d64df4c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 004220be5d784fce7fb075b9eac6a6f344d4416bfe1c9d64af6edb895b6ed1802e62cca9b52364746a2eba6b9b7b3a4418d3508f912954048d520a0e8106a5a1
|
7
|
+
data.tar.gz: d02dee405d04dd01b1bb135ecf90b7241e2feae917c911ad5785e8474eb04b5821a02e2478924c64a8b8458984c3691129bbd0265a326fef1f16350487f06ee7
|
data/README.md
CHANGED
@@ -318,8 +318,7 @@ We can also use a similar method to create a datatable of logs for just one user
|
|
318
318
|
When initialized with :for, the logs are scoped to any log where this id matches the User or Associated column.
|
319
319
|
|
320
320
|
```ruby
|
321
|
-
EffectiveLogsDatatable.new(for: @user
|
322
|
-
EffectiveLogsDatatable.new(for: [1, 2, 3]) # Users with ID 1, 2 and 3
|
321
|
+
EffectiveLogsDatatable.new(for: @user)
|
323
322
|
```
|
324
323
|
|
325
324
|
### Upgrade from 2.0
|
@@ -43,7 +43,7 @@ module Effective
|
|
43
43
|
# This is the User index event
|
44
44
|
def index
|
45
45
|
EffectiveResources.authorize!(self, :index, resource_scope.new(user: current_user, user_id: current_user.id))
|
46
|
-
@datatable = EffectiveLogsDatatable.new(self, for: current_user
|
46
|
+
@datatable = EffectiveLogsDatatable.new(self, for: current_user)
|
47
47
|
end
|
48
48
|
|
49
49
|
def html_part
|
@@ -44,24 +44,19 @@ class EffectiveLogsDatatable < Effective::Datatable
|
|
44
44
|
collection do
|
45
45
|
scope = EffectiveLogging.Log.deep.all
|
46
46
|
|
47
|
-
# Older syntax, pass by integer
|
48
|
-
if attributes[:for]
|
49
|
-
user_ids = Array(attributes[:for])
|
50
|
-
scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
|
51
|
-
end
|
52
|
-
|
53
47
|
# Newer syntax, pass by object
|
54
48
|
if attributes[:for_id] && attributes[:for_type]
|
55
49
|
scope = scope.where(associated_id: attributes[:for_id], associated_type: attributes[:for_type])
|
56
50
|
.or(scope.where(changes_to_id: attributes[:for_id], changes_to_type: attributes[:for_type]))
|
57
51
|
.or(scope.where(user_id: attributes[:for_id], user_type: attributes[:for_type]))
|
52
|
+
elsif attributes[:for] # Older syntax, pass by integer
|
53
|
+
user_ids = Array(attributes[:for])
|
54
|
+
scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
|
58
55
|
end
|
59
56
|
|
60
57
|
if attributes[:associated_id] && attributes[:associated_type]
|
61
58
|
scope = scope.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type])
|
62
|
-
|
63
|
-
|
64
|
-
if attributes[:associated]
|
59
|
+
elsif attributes[:associated]
|
65
60
|
scope = scope.where(associated: attributes[:associated])
|
66
61
|
end
|
67
62
|
|
@@ -20,7 +20,7 @@ module ActsAsLoggable
|
|
20
20
|
end
|
21
21
|
|
22
22
|
included do
|
23
|
-
has_many :logged_changes, -> {
|
23
|
+
has_many :logged_changes, -> { where(status: EffectiveLogging.log_changes_status).order(:id) }, as: :changes_to, class_name: 'Effective::Log'
|
24
24
|
|
25
25
|
log_changes_options = {
|
26
26
|
to: @acts_as_loggable_options[:to],
|
@@ -35,15 +35,15 @@ module ActsAsLoggable
|
|
35
35
|
|
36
36
|
self.send(:define_method, :log_changes_options) { log_changes_options }
|
37
37
|
|
38
|
-
after_create(unless: -> { EffectiveLogging.supressed? }) do
|
38
|
+
after_create(if: -> { log_changes? }, unless: -> { EffectiveLogging.supressed? }) do
|
39
39
|
::EffectiveLogging::ActiveRecordLogger.new(self, log_changes_options).created!
|
40
40
|
end
|
41
41
|
|
42
|
-
after_destroy(unless: -> { EffectiveLogging.supressed? }) do
|
42
|
+
after_destroy(if: -> { log_changes? }, unless: -> { EffectiveLogging.supressed? }) do
|
43
43
|
::EffectiveLogging::ActiveRecordLogger.new(self, log_changes_options).destroyed!
|
44
44
|
end
|
45
45
|
|
46
|
-
after_update(unless: -> { EffectiveLogging.supressed? }) do
|
46
|
+
after_update(if: -> { log_changes? }, unless: -> { EffectiveLogging.supressed? }) do
|
47
47
|
::EffectiveLogging::ActiveRecordLogger.new(self, log_changes_options).updated!
|
48
48
|
end
|
49
49
|
end
|
@@ -54,6 +54,11 @@ module ActsAsLoggable
|
|
54
54
|
|
55
55
|
# Regular instance methods
|
56
56
|
|
57
|
+
# Disable logging of changes for this resource
|
58
|
+
def log_changes?
|
59
|
+
true # Can be overridden to suppress logging
|
60
|
+
end
|
61
|
+
|
57
62
|
# Format the title of this attribute. Return nil to use the default attribute.titleize
|
58
63
|
def log_changes_formatted_attribute(attribute)
|
59
64
|
'Roles' if attribute == :roles_mask && defined?(EffectiveRoles) && respond_to?(:roles)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|