diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/chouette_controller.rb | 1 | ||||
| -rw-r--r-- | app/controllers/concerns/paper_trail_support.rb | 11 | ||||
| -rw-r--r-- | app/models/api/v1/api_key.rb | 1 | ||||
| -rw-r--r-- | app/models/calendar.rb | 2 | ||||
| -rw-r--r-- | app/models/compliance_check_set.rb | 1 | ||||
| -rw-r--r-- | app/models/compliance_control_set.rb | 1 |
7 files changed, 18 insertions, 1 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 diff --git a/app/models/api/v1/api_key.rb b/app/models/api/v1/api_key.rb index 767e65f3a..09c6f77ac 100644 --- a/app/models/api/v1/api_key.rb +++ b/app/models/api/v1/api_key.rb @@ -1,6 +1,7 @@ module Api module V1 class ApiKey < ::ActiveRecord::Base + has_paper_trail before_create :generate_access_token belongs_to :referential, :class_name => '::Referential' belongs_to :organisation, :class_name => '::Organisation' diff --git a/app/models/calendar.rb b/app/models/calendar.rb index bb38e74df..b2e73929f 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -3,7 +3,7 @@ require_relative 'calendar/date_value' require_relative 'calendar/period' class Calendar < ActiveRecord::Base - + has_paper_trail belongs_to :organisation has_many :time_tables diff --git a/app/models/compliance_check_set.rb b/app/models/compliance_check_set.rb index 80e499b74..00cf057f4 100644 --- a/app/models/compliance_check_set.rb +++ b/app/models/compliance_check_set.rb @@ -1,5 +1,6 @@ class ComplianceCheckSet < ActiveRecord::Base extend Enumerize + has_paper_trail belongs_to :referential belongs_to :compliance_control_set diff --git a/app/models/compliance_control_set.rb b/app/models/compliance_control_set.rb index deb46f5a1..41076fefc 100644 --- a/app/models/compliance_control_set.rb +++ b/app/models/compliance_control_set.rb @@ -1,4 +1,5 @@ class ComplianceControlSet < ActiveRecord::Base + has_paper_trail belongs_to :organisation has_many :compliance_control_blocks, dependent: :destroy has_many :compliance_controls, dependent: :destroy |
