Skip to content

Commit 723d43d

Browse files
Merge branch 'main' into 4241-change-agency-type-to-enum
2 parents 9fc8950 + 42c25ae commit 723d43d

24 files changed

+138
-178
lines changed

Gemfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ gem "rolify", "~> 6.0"
3737
gem "strong_migrations", "1.8.0"
3838
# used in events
3939
gem 'dry-struct'
40+
# Use solid_cache as a cache store
41+
gem "solid_cache", "~> 1.0"
4042

4143
##### JAVSCRIPT/CSS/ASSETS #######
4244

@@ -111,11 +113,6 @@ gem "nokogiri", ">= 1.10.4"
111113
gem "image_processing"
112114
gem "sprockets", "~> 4.2.1"
113115

114-
group :production do
115-
# Tool to detect unused code through knowing which methods are used in which files.
116-
gem 'coverband'
117-
end
118-
119116
group :production, :staging do
120117
# Reduce the noise of logs and include custom fields to it for easier access
121118
gem 'lograge'
@@ -218,7 +215,4 @@ if %w(mingw mswin x64_mingw jruby).include?(RUBY_PLATFORM)
218215
gem "tzinfo-data", "~> 1.2", platforms: %i(mingw mswin x64_mingw jruby)
219216
end
220217

221-
# Use Redis for Action Cable
222-
gem "redis", "~> 5.3"
223-
224218
gem "importmap-rails", "~> 2.1"

Gemfile.lock

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ GEM
143143
coderay (1.1.3)
144144
concurrent-ruby (1.3.4)
145145
connection_pool (2.4.1)
146-
coverband (6.1.2)
147-
redis (>= 3.0)
148146
crack (1.0.0)
149147
bigdecimal
150148
rexml
@@ -551,10 +549,6 @@ GEM
551549
rdoc (6.10.0)
552550
psych (>= 4.0.0)
553551
recaptcha (5.17.0)
554-
redis (5.3.0)
555-
redis-client (>= 0.22.0)
556-
redis-client (0.22.2)
557-
connection_pool
558552
regexp_parser (2.9.3)
559553
reline (0.6.0)
560554
io-console (~> 0.5)
@@ -652,6 +646,10 @@ GEM
652646
snaky_hash (2.0.1)
653647
hashie
654648
version_gem (~> 1.1, >= 1.1.1)
649+
solid_cache (1.0.6)
650+
activejob (>= 7.2)
651+
activerecord (>= 7.2)
652+
railties (>= 7.2)
655653
sprockets (4.2.1)
656654
concurrent-ruby (~> 1.0)
657655
rack (>= 2.2.4, < 4)
@@ -743,7 +741,6 @@ DEPENDENCIES
743741
capybara (~> 3.40)
744742
capybara-screenshot
745743
clockwork
746-
coverband
747744
cuprite
748745
database_cleaner-active_record (~> 2.2)
749746
debug (>= 1.0.0)
@@ -798,7 +795,6 @@ DEPENDENCIES
798795
rails-controller-testing
799796
rails-erd
800797
recaptcha
801-
redis (~> 5.3)
802798
rolify (~> 6.0)
803799
rspec-rails (~> 7.1.0)
804800
rubocop
@@ -808,6 +804,7 @@ DEPENDENCIES
808804
shoulda-matchers (~> 6.2)
809805
simple_form
810806
simplecov
807+
solid_cache (~> 1.0)
811808
sprockets (~> 4.2.1)
812809
standard (~> 1.40)
813810
standard-performance

app/controllers/organizations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def organization_params
9898
:enable_individual_requests, :enable_quantity_based_requests,
9999
:ytd_on_distribution_printout, :one_step_partner_invite,
100100
:hide_value_columns_on_receipt, :hide_package_column_on_receipt,
101-
:signature_for_distribution_pdf,
101+
:signature_for_distribution_pdf, :receive_email_on_requests,
102102
partner_form_fields: [],
103103
request_unit_names: []
104104
)

app/mailers/requests_confirmation_mailer.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ def confirmation_email(request)
44
@partner = request.partner
55
@request_items = fetch_items(request)
66
requestee_email = request.user_email
7-
mail(to: requestee_email, cc: @partner.email, subject: "#{@organization.name} - Requests Confirmation")
7+
# If the requestee organization has opted in to receiving an email when a
8+
# request is made, CC them
9+
cc = [@partner.email]
10+
if @organization.receive_email_on_requests
11+
cc.push(@organization.email)
12+
end
13+
cc.flatten!
14+
cc.compact!
15+
cc.uniq!
16+
mail(to: requestee_email, cc: cc, subject: "#{@organization.name} - Requests Confirmation")
817
end
918

1019
private

app/models/organization.rb

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# name :string
2121
# one_step_partner_invite :boolean default(FALSE), not null
2222
# partner_form_fields :text default([]), is an Array
23+
# receive_email_on_requests :boolean default(FALSE), not null
2324
# reminder_day :integer
2425
# repackage_essentials :boolean default(FALSE), not null
2526
# short_name :string
@@ -62,6 +63,8 @@ class Organization < ApplicationRecord
6263
has_many :product_drives
6364
has_many :donation_sites
6465
has_many :donations
66+
has_many :items
67+
has_many :item_categories
6568
has_many :manufacturers
6669
has_many :partners
6770
has_many :partner_groups
@@ -76,29 +79,6 @@ class Organization < ApplicationRecord
7679
has_many :request_units, class_name: 'Unit'
7780
end
7881

79-
has_many :items, dependent: :destroy do
80-
def other
81-
where(partner_key: "other")
82-
end
83-
84-
def during(date_start, date_end = Time.zone.now.strftime("%Y-%m-%d"))
85-
select("COUNT(line_items.id) as amount, name")
86-
.joins(:line_items)
87-
.where("line_items.created_at BETWEEN ? and ?", date_start, date_end)
88-
.group(:name)
89-
end
90-
91-
def top(limit = 5)
92-
order('count(line_items.id) DESC')
93-
.limit(limit)
94-
end
95-
96-
def bottom(limit = 5)
97-
order('count(line_items.id) ASC')
98-
.limit(limit)
99-
end
100-
end
101-
has_many :item_categories, dependent: :destroy
10282
has_many :barcode_items, dependent: :destroy do
10383
def all
10484
unscope(where: :organization_id).where("barcode_items.organization_id = ? OR barcode_items.barcodeable_type = ?", proxy_association.owner.id, "BaseItem")
@@ -170,10 +150,6 @@ def to_param
170150
short_name
171151
end
172152

173-
def display_users
174-
users.map(&:email).join(", ")
175-
end
176-
177153
def ordered_requests
178154
requests.order(status: :asc, updated_at: :desc)
179155
end
@@ -188,14 +164,6 @@ def address_changed?
188164
street_changed? || city_changed? || state_changed? || zipcode_changed?
189165
end
190166

191-
def address_inline
192-
address.split("\n").map(&:strip).join(", ")
193-
end
194-
195-
def total_inventory
196-
View::Inventory.total_inventory(id)
197-
end
198-
199167
def self.seed_items(organization = Organization.all)
200168
base_items = BaseItem.without_kit.map(&:to_h)
201169

@@ -239,10 +207,6 @@ def item_id_to_display_string_map
239207
end
240208
end
241209

242-
def valid_items_for_select
243-
valid_items.map { |item| [item[:name], item[:id]] }.sort
244-
end
245-
246210
def from_email
247211
return get_admin_email if email.blank?
248212

app/views/layouts/_lte_admin_sidebar.html.erb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,4 @@
130130
<% end %>
131131
</li>
132132

133-
<% if Rails.env.production? %>
134-
<li class="nav-item">
135-
<%= link_to("/coverage", class: "nav-link") do %>
136-
<i class="nav-icon fa-solid fa-chart-bar"></i>
137-
<p>Coverband</p>
138-
<% end %>
139-
</li>
140-
<% end %>
141-
142133
</ul>

app/views/organizations/_details.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@
194194
<%= humanize_boolean(@organization.hide_package_column_on_receipt) %>
195195
</p>
196196
</div>
197+
<div class="mb-4">
198+
<h3 class='font-bold'>Receive email when partner makes a request:</h3>
199+
<p>
200+
<%= humanize_boolean(@organization.receive_email_on_requests) %>
201+
</p>
202+
</div>
197203
<% if @organization.logo.attached? %>
198204
<div class="mb-4">
199205
<h3 class='font-bold'>Logo</h3>

app/views/organizations/edit.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
<%= f.input :one_step_partner_invite, label: 'Use One Step Invite and Approve partner process?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %>
132132
<%= f.input :hide_value_columns_on_receipt, label: 'Hide both value columns on distribution receipts?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %>
133133
<%= f.input :hide_package_column_on_receipt, label: 'Hide the package column on distribution receipts?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %>
134+
<%= f.input :receive_email_on_requests, label: 'Receive email when partner makes a request?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %>
134135

135136
<% default_email_text_hint = "You can use the variables <code>%{partner_name}</code>, <code>%{delivery_method}</code>, <code>%{distribution_date}</code>, and <code>%{comment}</code> to include the partner's name, delivery method, distribution date, and comments sent in the request." %>
136137
<%= f.input :default_email_text, label: "Distribution Email Content", hint: default_email_text_hint.html_safe do %>

config/cable.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
development:
2-
adapter: redis
3-
url: redis://localhost:6379/1
2+
adapter: async
43

54
test:
65
adapter: async

config/cache.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
default: &default
2+
store_options:
3+
# Cap age of oldest cache entry to fulfill retention policies
4+
max_age: <%= 14.days.to_i %>
5+
max_size: <%= 256.megabytes %>
6+
namespace: <%= Rails.env %>
7+
8+
development:
9+
<<: *default
10+
11+
test:
12+
<<: *default
13+
14+
production:
15+
database: cache
16+
<<: *default

0 commit comments

Comments
 (0)