Skip to content

Commit

Permalink
Merge 006d44d into aef5501
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp committed Jan 30, 2023
2 parents aef5501 + 006d44d commit 8763aa5
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ gem 'sqlite3', '~> 1.6.0'
# gem 'mysql2', '~> 0.4.10'

# This can only be removed with Rails 7.0
gem 'mail', '< 2.8.0'
gem 'psych', '< 4.0'

# Use SCSS for stylesheets
Expand Down Expand Up @@ -44,6 +45,7 @@ gem 'listen'
gem 'byebug', group: %i[development test]

gem 'active_hash'
gem 'audited'
gem 'cancancan', '~> 1.17'
gem 'carrierwave'
gem 'caxlsx_rails'
Expand All @@ -54,8 +56,6 @@ gem 'daemons'
gem 'date_validator'
gem 'devise'
gem 'devise_ichain_authenticatable', '>= 0.3.0'
gem 'espinita', git: 'https://github.com/michelson/espinita.git',
ref: '2dc027edc838ee5de0d68558f1758273ccc01636'
gem 'git'
gem 'inherited_resources'
gem 'kaminari'
Expand Down
32 changes: 5 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
GIT
remote: https://github.com/michelson/espinita.git
revision: 2dc027edc838ee5de0d68558f1758273ccc01636
ref: 2dc027edc838ee5de0d68558f1758273ccc01636
specs:
espinita (0.0.9)
rails (>= 4.0)
request_store

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -55,6 +46,8 @@ GEM
afm (0.2.2)
arel (8.0.0)
ast (2.4.2)
audited (5.0.2)
activerecord (>= 5.0, < 7.1)
autoprefixer-rails (10.4.7.0)
execjs (~> 2)
bcrypt (3.1.18)
Expand Down Expand Up @@ -116,7 +109,6 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.1)
date_validator (0.12.0)
activemodel (>= 3)
activesupport (>= 3)
Expand Down Expand Up @@ -203,11 +195,8 @@ GEM
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.8.0)
mail (2.7.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
Expand All @@ -217,15 +206,6 @@ GEM
mini_racer (0.6.3)
libv8-node (~> 16.10.0.0)
minitest (5.17.0)
net-imap (0.3.2)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
Expand Down Expand Up @@ -299,8 +279,6 @@ GEM
rdoc (6.3.3)
redcarpet (3.5.1)
regexp_parser (2.6.1)
request_store (1.5.1)
rack (>= 1.4)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
Expand Down Expand Up @@ -394,7 +372,6 @@ GEM
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.11)
timeout (0.3.1)
ttfunk (1.0.3)
tzinfo (1.2.10)
thread_safe (~> 0.1)
Expand All @@ -421,6 +398,7 @@ PLATFORMS

DEPENDENCIES
active_hash
audited
bootstrap-sass
byebug
cancancan (~> 1.17)
Expand All @@ -438,7 +416,6 @@ DEPENDENCIES
delayed_job_active_record
devise
devise_ichain_authenticatable (>= 0.3.0)
espinita!
exception_notification
git
haml-rails
Expand All @@ -448,6 +425,7 @@ DEPENDENCIES
kaminari
letter_opener_web
listen
mail (< 2.8.0)
mini_racer
pdf-reader
prawn (~> 0.13.0)
Expand Down
2 changes: 1 addition & 1 deletion app/models/budget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ class Budget < ApplicationRecord

validates :name, :amount, :currency, presence: true

auditable
audited
end
2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Event < ApplicationRecord
validates :name, :start_date, :end_date, :country_code, presence: true
validates :end_date, date: { after_or_equal_to: :start_date }

auditable
audited

default_scope { order('name asc') }

Expand Down
2 changes: 1 addition & 1 deletion app/models/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class Payment < ApplicationRecord

mount_uploader :file, AttachmentUploader

auditable except: [:file]
audited except: [:file]
end
2 changes: 1 addition & 1 deletion app/models/postal_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# Defined as a separate model in the shake of cleanest.
#
class PostalAddress < ApplicationRecord
auditable
audited
end
2 changes: 1 addition & 1 deletion app/models/reimbursement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Reimbursement < ApplicationRecord

mount_uploader :acceptance_file, AttachmentUploader

auditable except: [:acceptance_file]
audited except: [:acceptance_file]

# Synchronizes user_id and request_id
before_validation :set_user_id
Expand Down
2 changes: 1 addition & 1 deletion app/models/reimbursement_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ReimbursementAttachment < ApplicationRecord

mount_uploader :file, AttachmentUploader

auditable except: [:file]
audited except: [:file]

# Changed is ovewritten to avoid losing the already uploaded file when
# saving the reimbursement fails in some very specific situations
Expand Down
2 changes: 1 addition & 1 deletion app/models/reimbursement_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ class ReimbursementLink < ApplicationRecord

validates :reimbursement, :title, :url, presence: true

auditable
audited
end
2 changes: 1 addition & 1 deletion app/models/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ class Request < ApplicationRecord

validates :event, presence: true

auditable
audited
end
2 changes: 1 addition & 1 deletion app/models/request_expense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RequestExpense < ApplicationRecord

before_validation :set_authorized_amount

auditable
audited

# Scope needed by Request.expenses_sum
scope :by_attr_for_requests, lambda { |attr, req_ids|
Expand Down
2 changes: 1 addition & 1 deletion app/models/user_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UserProfile < ApplicationRecord

validates :role_id, presence: true

auditable
audited

scope :with_role, lambda { |role|
if role.is_a?(UserRole)
Expand Down
25 changes: 25 additions & 0 deletions db/migrate/20221210104059_update_columns_in_audits.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

class UpdateColumnsInAudits < ActiveRecord::Migration[5.1]
def change
add_column :audits, :remote_address, :string
add_column :audits, :username, :string
add_column :audits, :request_uuid, :string
add_column :audits, :associated_id, :integer
add_column :audits, :associated_type, :string

change_column_null :audits, :auditable_id, true
change_column_null :audits, :auditable_type, true
change_column_null :audits, :action, true
change_column_null :audits, :created_at, true

remove_index :audits, name: :auditable_index

add_index :audits, :request_uuid
add_index :audits, %i[auditable_type auditable_id version], name: :auditable_index
add_index :audits, %i[associated_type associated_id], name: :associated_index

remove_column :audits, :owner_id, :integer
remove_column :audits, :owner_type, :string
end
end
13 changes: 13 additions & 0 deletions db/migrate/20230130095633_merge_audit_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class MergeAuditTables < ActiveRecord::Migration[5.1]
def self.up
execute 'INSERT INTO audits(auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at) ' \
'SELECT auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at FROM espinita_audits;'
drop_table :espinita_audits
end

def self.down
raise IrreversibleMigration
end
end
37 changes: 13 additions & 24 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170720113427) do
ActiveRecord::Schema.define(version: 20230130095633) do

create_table "audits", force: :cascade do |t|
t.integer "auditable_id", null: false
t.string "auditable_type", null: false
t.integer "owner_id", null: false
t.string "owner_type", null: false
t.integer "auditable_id"
t.string "auditable_type"
t.integer "user_id"
t.string "user_type"
t.string "action", null: false
t.string "action"
t.text "audited_changes"
t.integer "version", default: 0
t.text "comment"
t.datetime "created_at", null: false
t.index ["auditable_id", "auditable_type", "version"], name: "auditable_index"
t.datetime "created_at"
t.string "remote_address"
t.string "username"
t.string "request_uuid"
t.integer "associated_id"
t.string "associated_type"
t.index ["associated_type", "associated_id"], name: "associated_index"
t.index ["auditable_type", "auditable_id", "version"], name: "auditable_index"
t.index ["created_at"], name: "index_audits_on_created_at"
t.index ["request_uuid"], name: "index_audits_on_request_uuid"
t.index ["user_id", "user_type"], name: "user_index"
end

Expand Down Expand Up @@ -80,22 +85,6 @@
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
end

create_table "espinita_audits", force: :cascade do |t|
t.string "auditable_type"
t.integer "auditable_id"
t.string "user_type"
t.integer "user_id"
t.text "audited_changes"
t.string "comment"
t.integer "version"
t.string "action"
t.string "remote_address"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["auditable_type", "auditable_id"], name: "index_espinita_audits_on_auditable_type_and_auditable_id"
t.index ["user_type", "user_id"], name: "index_espinita_audits_on_user_type_and_user_id"
end

create_table "event_emails", force: :cascade do |t|
t.text "to"
t.string "subject"
Expand Down

0 comments on commit 8763aa5

Please sign in to comment.