Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add papertrail to all things #3778

Merged
merged 8 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ GEM
zeitwerk (2.6.9)

PLATFORMS
arm64-darwin-20
arm64-darwin-21
arm64-darwin-22
x86_64-darwin-20
Expand Down
1 change: 1 addition & 0 deletions app/models/account_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# ndbn_member_id :bigint
#
class AccountRequest < ApplicationRecord
has_paper_trail
validates :name, presence: true
validates :email, presence: true, uniqueness: true
validates :request_details, presence: true, length: { minimum: 50 }
Expand Down
1 change: 1 addition & 0 deletions app/models/adjustment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#

class Adjustment < ApplicationRecord
has_paper_trail
belongs_to :organization
belongs_to :storage_location
belongs_to :user
Expand Down
1 change: 1 addition & 0 deletions app/models/annual_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# organization_id :bigint
#
class AnnualReport < ApplicationRecord
has_paper_trail
belongs_to :organization, inverse_of: :annual_reports
validates :year, numericality: { greater_than: 1900, less_than: 10_000 }

Expand Down
1 change: 1 addition & 0 deletions app/models/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#

class Audit < ApplicationRecord
has_paper_trail
belongs_to :user
belongs_to :organization
belongs_to :storage_location
Expand Down
1 change: 1 addition & 0 deletions app/models/barcode_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#

class BarcodeItem < ApplicationRecord
has_paper_trail
belongs_to :organization, optional: true
belongs_to :barcodeable, polymorphic: true, dependent: :destroy, counter_cache: :barcode_count

Expand Down
1 change: 1 addition & 0 deletions app/models/base_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#

class BaseItem < ApplicationRecord
has_paper_trail
has_many :items, dependent: :destroy, inverse_of: :base_item, foreign_key: :partner_key, primary_key: :partner_key
has_many :barcode_items, as: :barcodeable, dependent: :destroy

Expand Down
1 change: 1 addition & 0 deletions app/models/broadcast_announcement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# user_id :bigint not null
#
class BroadcastAnnouncement < ApplicationRecord
has_paper_trail
belongs_to :user
belongs_to :organization, optional: true
validates :link, format: URI::DEFAULT_PARSER.make_regexp(%w[http https]), allow_blank: true
Expand Down
1 change: 1 addition & 0 deletions app/models/county.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# updated_at :datetime not null
#
class County < ApplicationRecord
has_paper_trail
has_many :served_areas, class_name: "Partners::ServedArea", dependent: :destroy

SORT_ORDER = %w[US_County Other]
Expand Down
1 change: 1 addition & 0 deletions app/models/distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

class Distribution < ApplicationRecord
has_paper_trail
# Distributions are issued from a single storage location, so we associate
# them so that on-hand amounts can be verified
belongs_to :storage_location
Expand Down
1 change: 1 addition & 0 deletions app/models/donation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#

class Donation < ApplicationRecord
has_paper_trail
SOURCES = { product_drive: "Product Drive",
manufacturer: "Manufacturer",
donation_site: "Donation Site",
Expand Down
1 change: 1 addition & 0 deletions app/models/donation_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#

class DonationSite < ApplicationRecord
has_paper_trail
require "csv"

belongs_to :organization
Expand Down
3 changes: 1 addition & 2 deletions app/models/inventory_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
#

class InventoryItem < ApplicationRecord
MAX_INT = 2**31

has_paper_trail
MAX_INT = 2**31

EARLIEST_VERSION = "2021-08-02"

Expand Down
1 change: 1 addition & 0 deletions app/models/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#

class Item < ApplicationRecord
has_paper_trail
include Filterable
include Exportable
include Valuable
Expand Down
1 change: 1 addition & 0 deletions app/models/item_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# organization_id :integer not null
#
class ItemCategory < ApplicationRecord
has_paper_trail
validates :name, presence: true, uniqueness: { scope: :organization_id }
validates :organization, presence: true
validates :description, length: { maximum: 250 }
Expand Down
1 change: 1 addition & 0 deletions app/models/kit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# organization_id :integer not null
#
class Kit < ApplicationRecord
has_paper_trail
include Itemizable
include Filterable
include Valuable
Expand Down
1 change: 1 addition & 0 deletions app/models/kit_allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# storage_location_id :bigint not null
#
class KitAllocation < ApplicationRecord
has_paper_trail
include Itemizable
belongs_to :storage_location
end
1 change: 1 addition & 0 deletions app/models/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#

class LineItem < ApplicationRecord
has_paper_trail
include ItemQuantity
MAX_INT = 2**31
MIN_INT = -2**31
Expand Down
1 change: 1 addition & 0 deletions app/models/manufacturer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#

class Manufacturer < ApplicationRecord
has_paper_trail
belongs_to :organization

has_many :donations, inverse_of: :manufacturer, dependent: :destroy
Expand Down
1 change: 1 addition & 0 deletions app/models/ndbn_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# ndbn_member_id :bigint not null, primary key
#
class NDBNMember < ApplicationRecord
has_paper_trail
self.primary_key = "ndbn_member_id"

validates :ndbn_member_id, presence: true
Expand Down
1 change: 1 addition & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#

class Organization < ApplicationRecord
has_paper_trail
resourcify

DIAPER_APP_LOGO = Rails.root.join("public", "img", "humanessentials_logo.png")
Expand Down
1 change: 1 addition & 0 deletions app/models/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

class Partner < ApplicationRecord
has_paper_trail
resourcify
require "csv"

Expand Down
1 change: 1 addition & 0 deletions app/models/partner_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# organization_id :bigint
#
class PartnerGroup < ApplicationRecord
has_paper_trail
include Deadlinable

belongs_to :organization
Expand Down
1 change: 1 addition & 0 deletions app/models/partners/authorized_family_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
module Partners
class AuthorizedFamilyMember < Base
has_paper_trail
belongs_to :family
has_many :child_item_requests, dependent: :nullify

Expand Down
1 change: 1 addition & 0 deletions app/models/partners/child.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#
module Partners
class Child < Base
has_paper_trail
serialize :child_lives_with, Array
belongs_to :family
has_many :child_item_requests, dependent: :destroy
Expand Down
1 change: 1 addition & 0 deletions app/models/partners/child_item_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
module Partners
class ChildItemRequest < Base
has_paper_trail
belongs_to :item_request
belongs_to :child
belongs_to :authorized_family_member, optional: true
Expand Down
1 change: 1 addition & 0 deletions app/models/partners/family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#
module Partners
class Family < Base
has_paper_trail
belongs_to :partner, class_name: '::Partner'
has_many :children, dependent: :destroy
has_many :authorized_family_members, dependent: :destroy
Expand Down
1 change: 1 addition & 0 deletions app/models/partners/item_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
module Partners
class ItemRequest < Base
has_paper_trail
belongs_to :request, class_name: '::Request', foreign_key: :partner_request_id, inverse_of: :item_requests
has_many :child_item_requests, dependent: :destroy
has_many :children, through: :child_item_requests
Expand Down
1 change: 1 addition & 0 deletions app/models/partners/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#
module Partners
class Profile < Base
has_paper_trail
self.table_name = "partner_profiles"
belongs_to :partner
has_one :organization, through: :partner, class_name: "::Organization"
Expand Down
1 change: 1 addition & 0 deletions app/models/partners/served_area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#
module Partners
class ServedArea < ApplicationRecord
has_paper_trail
self.table_name = "partner_served_areas"
belongs_to :partner_profile, class_name: "Partners::Profile"
belongs_to :county
Expand Down
1 change: 1 addition & 0 deletions app/models/product_drive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#

class ProductDrive < ApplicationRecord
has_paper_trail
belongs_to :organization, optional: true
include Filterable

Expand Down
1 change: 1 addition & 0 deletions app/models/product_drive_participant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

class ProductDriveParticipant < ApplicationRecord
has_paper_trail
include Provideable
include Geocodable

Expand Down
1 change: 1 addition & 0 deletions app/models/purchase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

class Purchase < ApplicationRecord
has_paper_trail
include MoneyRails::ActionViewExtension

belongs_to :organization
Expand Down
1 change: 1 addition & 0 deletions app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# updated_at :datetime not null
#
class Question < ApplicationRecord
has_paper_trail
has_rich_text :answer
validates :answer, presence: true
validates :title, presence: true
Expand Down
1 change: 1 addition & 0 deletions app/models/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

class Request < ApplicationRecord
has_paper_trail
include Discard::Model
include Exportable

Expand Down
1 change: 1 addition & 0 deletions app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# resource_id :bigint
#
class Role < ApplicationRecord
has_paper_trail
has_and_belongs_to_many :users, join_table: :users_roles
accepts_nested_attributes_for :users

Expand Down
1 change: 1 addition & 0 deletions app/models/storage_location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# organization_id :integer
#
class StorageLocation < ApplicationRecord
has_paper_trail
require "csv"

WAREHOUSE_TYPES = [
Expand Down
1 change: 1 addition & 0 deletions app/models/transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#

class Transfer < ApplicationRecord
has_paper_trail
belongs_to :organization, inverse_of: :transfers
belongs_to :from, class_name: "StorageLocation", inverse_of: :transfers_from
belongs_to :to, class_name: "StorageLocation", inverse_of: :transfers_to
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#

class User < ApplicationRecord
has_paper_trail
rolify
include Discard::Model

Expand Down
1 change: 1 addition & 0 deletions app/models/users_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# user_id :bigint
#
class UsersRole < ApplicationRecord
has_paper_trail
belongs_to :user
belongs_to :role

Expand Down
1 change: 1 addition & 0 deletions app/models/vendor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

class Vendor < ApplicationRecord
has_paper_trail
include Provideable
include Geocodable

Expand Down
4 changes: 4 additions & 0 deletions spec/models/account_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,8 @@
.with(account_request_id: account_request.id)
expect(mail_double).to have_received(:deliver_later)
end

describe "versioning" do
it { is_expected.to be_versioned }
end
end
4 changes: 4 additions & 0 deletions spec/models/adjustment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,8 @@
expect(new_adjustment.save).to be_truthy
end
end

describe "versioning" do
it { is_expected.to be_versioned }
end
end
4 changes: 4 additions & 0 deletions spec/models/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,8 @@
expect(Audit.storage_locations_audited_for(@organization).to_a).to match_array([storage_location1, storage_location2])
end
end

describe "versioning" do
it { is_expected.to be_versioned }
end
end
4 changes: 4 additions & 0 deletions spec/models/barcode_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,8 @@
end
end
end

describe "versioning" do
it { is_expected.to be_versioned }
end
end
4 changes: 4 additions & 0 deletions spec/models/base_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@
end
end
end

describe "versioning" do
it { is_expected.to be_versioned }
end
end
4 changes: 4 additions & 0 deletions spec/models/broadcast_announcement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@
expect(BroadcastAnnouncement.filter_announcements(1).include?(announcement_3)).to be(false)
end
end

describe "versioning" do
it { is_expected.to be_versioned }
end
end
4 changes: 4 additions & 0 deletions spec/models/county_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@

RSpec.describe County, type: :model do
it { should have_many(:served_areas) }

describe "versioning" do
it { is_expected.to be_versioned }
end
end
Loading
Loading