mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-20 00:35:22 +00:00
Merge branch 'main' of github.com:hackclub/harbor
This commit is contained in:
commit
1a52fdf868
5 changed files with 27 additions and 2 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
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ class Avo::Resources::User < Avo::BaseResource
|
|||
field :slack_uid, as: :text
|
||||
field :avatar_url, as: :text
|
||||
field :is_admin, as: :boolean
|
||||
field :created_at, as: :date_time
|
||||
field :updated_at, as: :date_time
|
||||
field :created_at, as: :date_time, readonly: true
|
||||
field :updated_at, as: :date_time, readonly: true
|
||||
|
||||
# Show versions/history in the show page
|
||||
field :versions, as: :has_many
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
20
config/initializers/monkey_patches.rb
Normal file
20
config/initializers/monkey_patches.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# 🔧🐒
|
||||
|
||||
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