aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorXinhui2017-11-22 16:32:32 +0100
committerXinhui2017-11-28 12:21:33 +0100
commit86fd42a9136cb6eef87ecec3d0b2bcf579667798 (patch)
treea3ef5d442d91ea9cbf6608f2e9111691e8bd4567 /app/controllers
parentbc7888297ae545ae3c453c5c9481d22b37a0dad4 (diff)
downloadchouette-core-86fd42a9136cb6eef87ecec3d0b2bcf579667798.tar.bz2
Add has_paper_trail on models
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/chouette_controller.rb1
-rw-r--r--app/controllers/concerns/paper_trail_support.rb11
3 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6a9f6942f..97f5548ae 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,5 +1,7 @@
class ApplicationController < ActionController::Base
+ include PaperTrailSupport
include Pundit
+
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
# TODO : Delete hack to authorize Cross Request for js and json get request from javascript
diff --git a/app/controllers/chouette_controller.rb b/app/controllers/chouette_controller.rb
index e6e7c0a8a..3e4f3af27 100644
--- a/app/controllers/chouette_controller.rb
+++ b/app/controllers/chouette_controller.rb
@@ -1,3 +1,4 @@
class ChouetteController < InheritedResources::Base
+ include PaperTrailSupport
include ApplicationHelper
end
diff --git a/app/controllers/concerns/paper_trail_support.rb b/app/controllers/concerns/paper_trail_support.rb
new file mode 100644
index 000000000..4b0b1a7c7
--- /dev/null
+++ b/app/controllers/concerns/paper_trail_support.rb
@@ -0,0 +1,11 @@
+module PaperTrailSupport
+ extend ActiveSupport::Concern
+
+ included do
+ before_action :set_paper_trail_whodunnit
+
+ def user_for_paper_trail
+ current_user ? current_user.name : ''
+ end
+ end
+end