mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 22:15:14 +00:00
fix avo whodunnit and display user link
This commit is contained in:
parent
b109e2a0b5
commit
0fddb6cde1
4 changed files with 26 additions and 0 deletions
2
Gemfile
2
Gemfile
|
|
@ -89,3 +89,5 @@ group :test do
|
|||
gem "capybara"
|
||||
gem "selenium-webdriver"
|
||||
end
|
||||
|
||||
gem "avo-record_link_field", "~> 0.0.2"
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ GEM
|
|||
view_component (>= 3.7.0)
|
||||
zeitwerk (>= 2.6.12)
|
||||
avo-heroicons (0.1.1)
|
||||
avo-record_link_field (0.0.2)
|
||||
base64 (0.2.0)
|
||||
bcrypt_pbkdf (1.1.1)
|
||||
benchmark (0.4.0)
|
||||
|
|
@ -444,6 +445,7 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
avo (>= 3.2.1)
|
||||
avo-record_link_field (~> 0.0.2)
|
||||
bootsnap
|
||||
brakeman
|
||||
capybara
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class Avo::Resources::Version < Avo::BaseResource
|
|||
field :item_id, as: :number
|
||||
field :event, as: :text
|
||||
field :whodunnit, as: :text
|
||||
field :user, as: :record_link
|
||||
field :object, as: :code
|
||||
field :created_at, as: :date_time
|
||||
end
|
||||
|
|
|
|||
21
config/initializers/monkey_patches.rb
Normal file
21
config/initializers/monkey_patches.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# 🔧🐒
|
||||
|
||||
Rails.configuration.to_prepare do
|
||||
Avo::BaseApplicationController.class_eval do
|
||||
before_action :set_paper_trail_whodunnit
|
||||
def user_for_paper_trail
|
||||
Avo::Current.user&.id
|
||||
end
|
||||
end
|
||||
|
||||
PaperTrail::Version.class_eval do
|
||||
def user
|
||||
begin
|
||||
User.find(whodunnit) if whodunnit
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Add table
Reference in a new issue