effective_logging 1.6.0 → 1.7.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 +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +31 -8
- data/app/controllers/admin/logs_controller.rb +1 -1
- data/app/controllers/admin/trash_controller.rb +28 -0
- data/app/controllers/effective/trash_controller.rb +44 -0
- data/app/helpers/effective_logging_helper.rb +3 -1
- data/app/models/concerns/acts_as_trashable.rb +40 -0
- data/app/models/effective/datatables/trash.rb +53 -0
- data/app/models/effective/log.rb +21 -1
- data/app/views/admin/trash/_actions.html.haml +15 -0
- data/app/views/admin/trash/index.html.haml +3 -0
- data/app/views/admin/trash/show.html.haml +4 -0
- data/app/views/effective/logs/_log.html.haml +8 -3
- data/app/views/effective/trash/index.html.haml +6 -0
- data/app/views/effective/trash/show.html.haml +3 -0
- data/config/effective_logging.rb +10 -0
- data/config/routes.rb +11 -1
- data/lib/effective_logging/active_record_logger.rb +14 -8
- data/lib/effective_logging/engine.rb +2 -0
- data/lib/effective_logging/log_changes_user.rb +8 -4
- data/lib/effective_logging/version.rb +1 -1
- data/lib/effective_logging.rb +10 -5
- metadata +11 -3
- data/Rakefile +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad0a757a423a0d5b68a2d92bb665772c2e5ca8c0
|
4
|
+
data.tar.gz: 8d779cd00a570d021e4685dd2c3c6ab4235f97bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 722d36f2d30fe97be38fb6af0f4d0bde3e27595ebbc25cfe17de3c1805127984dec04e5af9692805639d6dc5e64588700c612c2814f0fdd9b88fd1bc752fd0cb
|
7
|
+
data.tar.gz: 27bf043f29c30a5e71b4ae0e458cc8b1526ce3875879709ddd244681ca9150eb835d732b1db7ac8987640274e5f9ffb6f7333754360c368069b864ebbbe51d10
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,7 @@ Automatically logs any email sent by the application, any successful user login
|
|
16
16
|
|
17
17
|
Has an effective_datatables driven admin interface to display and search/sort/filter all logs.
|
18
18
|
|
19
|
+
Audits changes and performs Trash restore functionality for Active Record objects.
|
19
20
|
|
20
21
|
## Getting Started
|
21
22
|
|
@@ -208,14 +209,6 @@ class Post < ActiveRecord::Base
|
|
208
209
|
end
|
209
210
|
```
|
210
211
|
|
211
|
-
And to your controller:
|
212
|
-
|
213
|
-
```ruby
|
214
|
-
class ApplicationController < ActionController::Base
|
215
|
-
before_action :set_log_changes_user
|
216
|
-
end
|
217
|
-
```
|
218
|
-
|
219
212
|
Then to see the log for this resource, on any view:
|
220
213
|
|
221
214
|
```erb
|
@@ -254,6 +247,36 @@ def log_changes_formatted_value(attribute, value)
|
|
254
247
|
end
|
255
248
|
```
|
256
249
|
|
250
|
+
### Trash & Restore
|
251
|
+
|
252
|
+
This gem provides a fully functional Trash implementation that can be
|
253
|
+
used to delete and restore active record objects in any rails application.
|
254
|
+
|
255
|
+
Add to your model:
|
256
|
+
|
257
|
+
```ruby
|
258
|
+
class Post < ActiveRecord::Base
|
259
|
+
acts_as_trashable
|
260
|
+
end
|
261
|
+
```
|
262
|
+
|
263
|
+
The `acts_as_trashable` mixin sets up `before_destroy` hook and copies the now-deleted attributes to an `Effective::Log` object.
|
264
|
+
|
265
|
+
Visit `/trash`, or `/admin/trash` to restore them.
|
266
|
+
|
267
|
+
The above routes require the following, user specific, permissions:
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
can :restore, Effective::Log, user_id: user.id
|
271
|
+
```
|
272
|
+
|
273
|
+
and for admin:
|
274
|
+
|
275
|
+
```ruby
|
276
|
+
can :restore, Effective::Log
|
277
|
+
can :admin, :effective_logging
|
278
|
+
```
|
279
|
+
|
257
280
|
### Logging From JavaScript
|
258
281
|
|
259
282
|
First, require the javascript in your application.js:
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This copies the permissions of The Logs controller
|
2
|
+
|
3
|
+
module Admin
|
4
|
+
class TrashController < ApplicationController
|
5
|
+
respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
|
6
|
+
|
7
|
+
layout (EffectiveLogging.layout.kind_of?(Hash) ? EffectiveLogging.layout[:admin_trash] : EffectiveLogging.layout)
|
8
|
+
|
9
|
+
skip_log_page_views quiet: true
|
10
|
+
helper EffectiveLoggingHelper
|
11
|
+
|
12
|
+
def index
|
13
|
+
@datatable = Effective::Datatables::Trash.new()
|
14
|
+
@page_title = 'Trash'
|
15
|
+
|
16
|
+
EffectiveLogging.authorized?(self, :restore, Effective::Log)
|
17
|
+
EffectiveLogging.authorized?(self, :admin, :effective_logging)
|
18
|
+
end
|
19
|
+
|
20
|
+
def show
|
21
|
+
@trash = Effective::Log.trash.find(params[:id])
|
22
|
+
@page_title = "Trash item - #{@trash.to_s}"
|
23
|
+
|
24
|
+
EffectiveLogging.authorized?(self, :restore, @trash)
|
25
|
+
EffectiveLogging.authorized?(self, :admin, :effective_logging)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Effective
|
2
|
+
class TrashController < ApplicationController
|
3
|
+
if respond_to?(:before_action) # Devise
|
4
|
+
before_action :authenticate_user!
|
5
|
+
else
|
6
|
+
before_filter :authenticate_user!
|
7
|
+
end
|
8
|
+
|
9
|
+
# This is the User index event
|
10
|
+
def index
|
11
|
+
@datatable = Effective::Datatables::Trash.new(user_id: current_user.id)
|
12
|
+
@page_title = 'Trash'
|
13
|
+
|
14
|
+
EffectiveLogging.authorized?(self, :restore, Effective::Log.new(user_id: current_user.id))
|
15
|
+
end
|
16
|
+
|
17
|
+
# This is the User show event
|
18
|
+
def show
|
19
|
+
@trash = Effective::Log.trash.find(params[:id])
|
20
|
+
@page_title = "Trash item - #{@trash.to_s}"
|
21
|
+
|
22
|
+
EffectiveLogging.authorized?(self, :restore, @trash)
|
23
|
+
end
|
24
|
+
|
25
|
+
def restore
|
26
|
+
@trash = Effective::Log.trash.find(params[:id])
|
27
|
+
EffectiveLogging.authorized?(self, :restore, @trash)
|
28
|
+
|
29
|
+
Effective::Log.transaction do
|
30
|
+
begin
|
31
|
+
@trash.restore_trashable!
|
32
|
+
@trash.destroy!
|
33
|
+
flash[:success] = "Successfully restored #{@trash}"
|
34
|
+
rescue => e
|
35
|
+
flash[:danger] = "Unable to restore: #{e.message}"
|
36
|
+
raise ActiveRecord::Rollback
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
redirect_back(fallback_location: effective_logging.trash_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -8,13 +8,15 @@ module EffectiveLoggingHelper
|
|
8
8
|
when 'info' ; 'info'
|
9
9
|
when 'warning' ; 'warning'
|
10
10
|
when 'error' ; 'danger'
|
11
|
+
when 'trashed' ; 'default'
|
11
12
|
else 'primary'
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
def render_log(log)
|
16
|
-
render(:
|
17
|
+
render(partial: 'effective/logs/log', locals: {:log => log})
|
17
18
|
end
|
19
|
+
alias_method :render_trash, :render_log
|
18
20
|
|
19
21
|
def parents_of_log(log)
|
20
22
|
parents = [log.parent]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ActsAsTrashable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
module ActiveRecord
|
5
|
+
def acts_as_trashable(*options)
|
6
|
+
@acts_as_trashable_options = options.try(:first) || {}
|
7
|
+
|
8
|
+
unless @acts_as_trashable_options.kind_of?(Hash)
|
9
|
+
raise ArgumentError.new("invalid arguments passed to (effective_trash) acts_as_trashable. Expecting no options.")
|
10
|
+
end
|
11
|
+
|
12
|
+
include ::ActsAsTrashable
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
included do
|
17
|
+
has_one :trash, -> { where(status: EffectiveLogging.trashable_status) }, as: :associated, class_name: Effective::Log
|
18
|
+
|
19
|
+
before_destroy do
|
20
|
+
EffectiveLogging::ActiveRecordLogger.new(self, acts_as_trashable_options).trashed!
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parse Options
|
25
|
+
acts_as_trashable_options = {
|
26
|
+
only: Array(@acts_as_trashable_options[:only]).map { |attribute| attribute.to_s },
|
27
|
+
except: Array(@acts_as_trashable_options[:except]).map { |attribute| attribute.to_s },
|
28
|
+
additionally: Array(@acts_as_trashable_options[:additionally]).map { |attribute| attribute.to_s }
|
29
|
+
}
|
30
|
+
|
31
|
+
self.send(:define_method, :acts_as_trashable_options) { acts_as_trashable_options }
|
32
|
+
end
|
33
|
+
|
34
|
+
module ClassMethods
|
35
|
+
end
|
36
|
+
|
37
|
+
# Regular instance methods
|
38
|
+
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
if defined?(EffectiveDatatables)
|
2
|
+
module Effective
|
3
|
+
module Datatables
|
4
|
+
class Trash < Effective::Datatable
|
5
|
+
include EffectiveLoggingHelper
|
6
|
+
|
7
|
+
datatable do
|
8
|
+
default_order :created_at, :desc
|
9
|
+
|
10
|
+
table_column :created_at, label: 'Destroyed at'
|
11
|
+
table_column :id, visible: false
|
12
|
+
|
13
|
+
unless attributes[:user_id] || attributes[:user] || (attributes[:user] == false)
|
14
|
+
table_column :user, label: 'Destroyed by', visible: false
|
15
|
+
end
|
16
|
+
|
17
|
+
table_column :associated_type, label: 'Type'
|
18
|
+
table_column :associated_id, label: 'Original Id', visible: false
|
19
|
+
table_column :message, label: 'Item'
|
20
|
+
|
21
|
+
table_column :details, visible: true, sortable: false do |trash|
|
22
|
+
tableize_hash(trash.details.except(:trash), th: true, sub_th: false, width: '100%')
|
23
|
+
end
|
24
|
+
|
25
|
+
unless attributes[:actions] == false
|
26
|
+
actions_column partial: 'admin/trash/actions', partial_local: :trash
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# A nil attributes[:log_id] means give me all the top level log entries
|
31
|
+
# If we set a log_id then it's for sub logs
|
32
|
+
def collection
|
33
|
+
collection = Effective::Log.trash.includes(:user)
|
34
|
+
|
35
|
+
if attributes[:user_id].present?
|
36
|
+
collection = collection.where(user_id: attributes[:user_id])
|
37
|
+
end
|
38
|
+
|
39
|
+
if attributes[:user].present?
|
40
|
+
collection = collection.where(user: attributes[:user])
|
41
|
+
end
|
42
|
+
|
43
|
+
if attributes[:associated_id] && attributes[:associated_type]
|
44
|
+
collection = collection.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type])
|
45
|
+
end
|
46
|
+
|
47
|
+
collection
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/app/models/effective/log.rb
CHANGED
@@ -27,10 +27,23 @@ module Effective
|
|
27
27
|
# end
|
28
28
|
|
29
29
|
validates :message, presence: true
|
30
|
-
validates :status, presence: true, inclusion: { in: (EffectiveLogging.statuses + [EffectiveLogging.log_changes_status]) }
|
30
|
+
validates :status, presence: true, inclusion: { in: (EffectiveLogging.statuses + [EffectiveLogging.log_changes_status, EffectiveLogging.trashable_status]) }
|
31
31
|
|
32
32
|
default_scope -> { order(updated_at: :desc) }
|
33
33
|
|
34
|
+
scope :logged_changes, -> { where(status: EffectiveLogging.log_changes_status)}
|
35
|
+
scope :changes, -> { where(status: EffectiveLogging.log_changes_status)}
|
36
|
+
scope :trash, -> { where(status: EffectiveLogging.trashable_status)}
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
case status
|
40
|
+
when EffectiveLogging.trashable_status
|
41
|
+
[associated_type, associated_id].join(' ').presence || 'New Trash item'
|
42
|
+
else
|
43
|
+
"Log #{id}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
34
47
|
def log(message, status = EffectiveLogging.statuses.first, options = {})
|
35
48
|
EffectiveLogger.log(message, status, (options || {}).merge({:parent => self}))
|
36
49
|
end
|
@@ -39,6 +52,13 @@ module Effective
|
|
39
52
|
self[:details] || {}
|
40
53
|
end
|
41
54
|
|
55
|
+
# So this is a Trash item
|
56
|
+
# When we delete ourselves, we restore this trash item first
|
57
|
+
def restore_trashable!
|
58
|
+
raise 'no attributes to restore from' unless details.kind_of?(Hash) && details[:attributes].present?
|
59
|
+
associated_type.constantize.new(details[:attributes]).save!
|
60
|
+
end
|
61
|
+
|
42
62
|
# def next_log
|
43
63
|
# @next_log ||= Log.unscoped.order(:id).where(:parent_id => self.parent_id).where('id > ?', self.id).first
|
44
64
|
# end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
:ruby
|
2
|
+
show_path =
|
3
|
+
if datatables_active_admin_path?
|
4
|
+
admin_effective_trash_path(trash)
|
5
|
+
elsif datatables_admin_path?
|
6
|
+
effective_logging.admin_trash_path(trash)
|
7
|
+
else
|
8
|
+
effective_logging.trash_path(trash)
|
9
|
+
end
|
10
|
+
|
11
|
+
= link_to show_path, title: 'view' do
|
12
|
+
%span.glyphicon.glyphicon-eye-open
|
13
|
+
|
14
|
+
= link_to effective_logging.restore_trash_path(trash), title: 'Restore', data: {confirm: 'Restore this item?'} do
|
15
|
+
%span.glyphicon.glyphicon-retweet
|
@@ -5,9 +5,14 @@
|
|
5
5
|
= ' > '
|
6
6
|
%strong= log.message
|
7
7
|
.pull-right
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
- if log.prev_log.present?
|
9
|
+
= link_to '< Prev', request.fullpath.gsub(log.to_param, log.prev_log.try(:to_param).to_s)
|
10
|
+
|
11
|
+
- if log.prev_log && log.next_log
|
12
|
+
= ' - '
|
13
|
+
|
14
|
+
- if log.next_log.present?
|
15
|
+
= link_to 'Next >', request.fullpath.gsub(log.to_param, log.next_log.try(:to_param).to_s)
|
11
16
|
|
12
17
|
.panel-body
|
13
18
|
.row
|
data/config/effective_logging.rb
CHANGED
@@ -29,6 +29,13 @@ EffectiveLogging.setup do |config|
|
|
29
29
|
# Admin Screens Layout Settings
|
30
30
|
config.layout = 'application' # All EffectiveLogging controllers will use this layout
|
31
31
|
|
32
|
+
# config.layout = {
|
33
|
+
# logs: 'application',
|
34
|
+
# trash: 'application',
|
35
|
+
# admin_logs: 'admin',
|
36
|
+
# admin_trash: 'admin'
|
37
|
+
# }
|
38
|
+
|
32
39
|
# All statuses defined here, as well as 'info', 'success', and 'error' (hardcoded) will be created as
|
33
40
|
# EffectiveLogger.info('my message') macros
|
34
41
|
config.additional_statuses = []
|
@@ -43,4 +50,7 @@ EffectiveLogging.setup do |config|
|
|
43
50
|
# Log all successful user login attempts
|
44
51
|
config.user_logins_enabled = true
|
45
52
|
config.user_logouts_enabled = false
|
53
|
+
|
54
|
+
# Enable the /trash, /admin/trash and /trash/:id/restore routes. Doesn't affect acts_as_trashable itself.
|
55
|
+
config.trash_enabled = true
|
46
56
|
end
|
data/config/routes.rb
CHANGED
@@ -2,14 +2,24 @@ EffectiveLogging::Engine.routes.draw do
|
|
2
2
|
scope :module => 'effective' do
|
3
3
|
# Create is our javascript POST event for EffectiveLogging from JS side
|
4
4
|
# The show and index routes are for user specific logs
|
5
|
-
resources :logs, :
|
5
|
+
resources :logs, only: [:create, :index, :show] do
|
6
6
|
member { get :html_part }
|
7
7
|
end
|
8
|
+
|
9
|
+
if EffectiveLogging.trash_enabled
|
10
|
+
resources :trash, only: [:index, :show] do
|
11
|
+
member { get :restore }
|
12
|
+
end
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
if defined?(EffectiveDatatables)
|
11
17
|
namespace :admin do
|
12
18
|
resources :logs, :only => [:index, :show]
|
19
|
+
|
20
|
+
if EffectiveLogging.trash_enabled
|
21
|
+
resources :trash, only: [:index, :show]
|
22
|
+
end
|
13
23
|
end
|
14
24
|
end
|
15
25
|
|
@@ -25,19 +25,24 @@ module EffectiveLogging
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
# before_destroy
|
29
|
+
def trashed!
|
30
|
+
log((resource.to_s rescue ''), status: EffectiveLogging.trashable_status, details: applicable(attributes))
|
31
|
+
end
|
32
|
+
|
28
33
|
# before_destroy
|
29
34
|
def destroyed!
|
30
|
-
log('Deleted', applicable(attributes))
|
35
|
+
log('Deleted', details: applicable(attributes))
|
31
36
|
end
|
32
37
|
|
33
38
|
# after_commit
|
34
39
|
def created!
|
35
|
-
log('Created', applicable(attributes))
|
40
|
+
log('Created', details: applicable(attributes))
|
36
41
|
end
|
37
42
|
|
38
43
|
# after_commit
|
39
44
|
def updated!
|
40
|
-
log('Updated', applicable(attributes))
|
45
|
+
log('Updated', details: applicable(attributes))
|
41
46
|
end
|
42
47
|
|
43
48
|
# before_save
|
@@ -53,9 +58,9 @@ module EffectiveLogging
|
|
53
58
|
end || attribute.titleize
|
54
59
|
|
55
60
|
if after.present?
|
56
|
-
log("#{attribute} changed from #{before.presence || BLANK} to #{after.presence || BLANK}", { attribute: attribute, before: before, after: after })
|
61
|
+
log("#{attribute} changed from #{before.presence || BLANK} to #{after.presence || BLANK}", details: { attribute: attribute, before: before, after: after })
|
57
62
|
else
|
58
|
-
log("#{attribute} set to #{before || BLANK}", { attribute: attribute, value: before })
|
63
|
+
log("#{attribute} set to #{before || BLANK}", details: { attribute: attribute, value: before })
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
@@ -79,6 +84,7 @@ module EffectiveLogging
|
|
79
84
|
|
80
85
|
# Collect to_s representations for all has_one associations
|
81
86
|
(resource.class.try(:reflect_on_all_associations, :has_one) || []).each do |association|
|
87
|
+
next if association.name == :trash && resource.respond_to?(:acts_as_trashable_options) # We skip our own association
|
82
88
|
attributes[association.name] = resource.send(association.name).to_s.presence || 'nil'
|
83
89
|
end
|
84
90
|
|
@@ -109,10 +115,10 @@ module EffectiveLogging
|
|
109
115
|
|
110
116
|
private
|
111
117
|
|
112
|
-
def log(message, details
|
118
|
+
def log(message, status: EffectiveLogging.log_changes_status, details: {})
|
113
119
|
logger.logged_changes.build(
|
114
|
-
user: EffectiveLogging.
|
115
|
-
status:
|
120
|
+
user: EffectiveLogging.current_user,
|
121
|
+
status: status,
|
116
122
|
message: "#{"\t" * depth}#{options[:prefix]}#{message}",
|
117
123
|
details: details
|
118
124
|
).tap { |log| log.save }
|
@@ -29,6 +29,7 @@ module EffectiveLogging
|
|
29
29
|
initializer 'effective_logging.active_record' do |app|
|
30
30
|
ActiveSupport.on_load :active_record do
|
31
31
|
ActiveRecord::Base.extend(ActsAsLoggable::ActiveRecord)
|
32
|
+
ActiveRecord::Base.extend(ActsAsTrashable::ActiveRecord)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -36,6 +37,7 @@ module EffectiveLogging
|
|
36
37
|
initializer 'effective_logging.log_changes_action_controller' do |app|
|
37
38
|
ActiveSupport.on_load :action_controller do
|
38
39
|
ActionController::Base.include(EffectiveLogging::LogChangesUser)
|
40
|
+
ActionController::Base.send(:before_action, :set_effective_logging_current_user)
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -2,16 +2,20 @@ module EffectiveLogging
|
|
2
2
|
module LogChangesUser
|
3
3
|
|
4
4
|
# Add me to your ApplicationController
|
5
|
-
# before_action :
|
5
|
+
# before_action :set_effective_logging_current_user
|
6
6
|
|
7
|
-
def
|
7
|
+
def set_effective_logging_current_user
|
8
8
|
if respond_to?(:current_user)
|
9
|
-
EffectiveLogging.
|
9
|
+
EffectiveLogging.current_user = current_user
|
10
10
|
else
|
11
|
-
raise "(effective_logging)
|
11
|
+
raise "(effective_logging) set_effective_logging_current_user expects a current_user() method to be available"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
def set_log_changes_user
|
16
|
+
# No longer need to call this
|
17
|
+
end
|
18
|
+
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
data/lib/effective_logging.rb
CHANGED
@@ -15,6 +15,7 @@ module EffectiveLogging
|
|
15
15
|
mattr_accessor :emails_enabled
|
16
16
|
mattr_accessor :user_logins_enabled
|
17
17
|
mattr_accessor :user_logouts_enabled
|
18
|
+
mattr_accessor :trash_enabled
|
18
19
|
|
19
20
|
def self.setup
|
20
21
|
yield self
|
@@ -43,13 +44,17 @@ module EffectiveLogging
|
|
43
44
|
'logged change'.freeze
|
44
45
|
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
@log_changes_user = user
|
47
|
+
def self.trashable_status
|
48
|
+
'trashed'.freeze
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
# This is set by the "set_effective_logging_current_user" before_filter.
|
52
|
+
def self.current_user=(user)
|
53
|
+
@effective_logging_current_user = user
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.current_user
|
57
|
+
@effective_logging_current_user
|
53
58
|
end
|
54
59
|
|
55
60
|
end
|
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: 1.
|
4
|
+
version: 1.7.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: 2017-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -90,15 +90,18 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- MIT-LICENSE
|
92
92
|
- README.md
|
93
|
-
- Rakefile
|
94
93
|
- app/assets/javascripts/effective_logging.js
|
95
94
|
- app/assets/javascripts/effective_logging/effective_logger.js.coffee.erb
|
96
95
|
- app/controllers/admin/logs_controller.rb
|
96
|
+
- app/controllers/admin/trash_controller.rb
|
97
97
|
- app/controllers/effective/logs_controller.rb
|
98
|
+
- app/controllers/effective/trash_controller.rb
|
98
99
|
- app/helpers/effective_logging_helper.rb
|
99
100
|
- app/models/concerns/acts_as_loggable.rb
|
101
|
+
- app/models/concerns/acts_as_trashable.rb
|
100
102
|
- app/models/effective/access_denied.rb
|
101
103
|
- app/models/effective/datatables/logs.rb
|
104
|
+
- app/models/effective/datatables/trash.rb
|
102
105
|
- app/models/effective/log.rb
|
103
106
|
- app/models/effective_logger.rb
|
104
107
|
- app/views/active_admin/effective_logging/logs/index.html.haml
|
@@ -106,9 +109,14 @@ files:
|
|
106
109
|
- app/views/admin/logs/_actions.html.haml
|
107
110
|
- app/views/admin/logs/index.html.haml
|
108
111
|
- app/views/admin/logs/show.html.haml
|
112
|
+
- app/views/admin/trash/_actions.html.haml
|
113
|
+
- app/views/admin/trash/index.html.haml
|
114
|
+
- app/views/admin/trash/show.html.haml
|
109
115
|
- app/views/effective/logs/_log.html.haml
|
110
116
|
- app/views/effective/logs/index.html.haml
|
111
117
|
- app/views/effective/logs/show.html.haml
|
118
|
+
- app/views/effective/trash/index.html.haml
|
119
|
+
- app/views/effective/trash/show.html.haml
|
112
120
|
- config/effective_logging.rb
|
113
121
|
- config/routes.rb
|
114
122
|
- db/migrate/01_create_effective_logging.rb.erb
|
data/Rakefile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
begin
|
3
|
-
require 'bundler/setup'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
|
8
|
-
# Testing tasks
|
9
|
-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
10
|
-
load 'rails/tasks/engine.rake'
|
11
|
-
|
12
|
-
Bundler::GemHelper.install_tasks
|
13
|
-
|
14
|
-
require 'rspec/core'
|
15
|
-
require 'rspec/core/rake_task'
|
16
|
-
|
17
|
-
desc "Run all specs in spec directory (excluding plugin specs)"
|
18
|
-
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
19
|
-
|
20
|
-
task :default => :spec
|