Skip to content

Commit 5c2612a

Browse files
Merge branch 'main' into 3689-check-double-clicks-on-submit
2 parents 12bed26 + 3e76a21 commit 5c2612a

26 files changed

+382
-55
lines changed

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ gem "turbo-rails"
5151
# Sprinkle a little JS to add interactivity
5252
gem "stimulus-rails"
5353
# Use JS import maps to manage JS without transpiling or bundling.
54-
gem "importmap-rails", "~> 2.1"
54+
gem "importmap-rails", "~> 2.2"
5555

5656
##### VIEWS/CONTROLLERS #####
5757

@@ -61,6 +61,8 @@ gem "filterrific"
6161
gem "jbuilder"
6262
# Pagination of models for use in views.
6363
gem "kaminari"
64+
# Prevents cookie overflow errors when storing large flash messages.
65+
gem 'memflash'
6466
# Web-based authorization framework.
6567
gem "omniauth"
6668
# Required to avoid authentication issues with Rails.

Gemfile.lock

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ GEM
133133
autoprefixer-rails (>= 9.1.0)
134134
popper_js (>= 2.11.6, < 3)
135135
sassc-rails (>= 2.0.0)
136-
brakeman (7.0.2)
136+
brakeman (7.1.0)
137137
racc
138-
bugsnag (6.27.1)
138+
bugsnag (6.28.0)
139139
concurrent-ruby (~> 1.0)
140140
builder (3.3.0)
141141
bullet (8.0.8)
@@ -174,7 +174,7 @@ GEM
174174
database_cleaner-core (~> 2.0.0)
175175
database_cleaner-core (2.0.1)
176176
date (3.4.1)
177-
debug (1.9.2)
177+
debug (1.11.0)
178178
irb (~> 1.10)
179179
reline (>= 0.3.8)
180180
debug_inspector (1.2.0)
@@ -194,7 +194,7 @@ GEM
194194
railties (>= 4.1.0)
195195
responders
196196
warden (~> 1.2.3)
197-
devise_invitable (2.0.10)
197+
devise_invitable (2.0.11)
198198
actionmailer (>= 5.0)
199199
devise (>= 4.6)
200200
diff-lcs (1.6.2)
@@ -228,7 +228,7 @@ GEM
228228
dry-inflector (~> 1.0)
229229
dry-logic (~> 1.4)
230230
zeitwerk (~> 2.6)
231-
erb (5.0.1)
231+
erb (5.0.2)
232232
erb_lint (0.9.0)
233233
activesupport
234234
better_html (>= 2.0.1)
@@ -292,7 +292,8 @@ GEM
292292
rack-protection (>= 1.5.3, < 5.0.0)
293293
rack-session (>= 1.0.2, < 3.0.0)
294294
sanitize (< 8)
295-
foreman (0.88.1)
295+
foreman (0.90.0)
296+
thor (~> 1.4)
296297
formatador (1.1.0)
297298
geocoder (1.8.5)
298299
base64 (>= 0.1.0)
@@ -323,11 +324,11 @@ GEM
323324
ostruct
324325
ice_cube (0.17.0)
325326
ice_nine (0.11.2)
326-
importmap-rails (2.1.0)
327+
importmap-rails (2.2.2)
327328
actionpack (>= 6.0.0)
328329
activesupport (>= 6.0.0)
329330
railties (>= 6.0.0)
330-
io-console (0.8.0)
331+
io-console (0.8.1)
331332
irb (1.15.2)
332333
pp (>= 0.6.0)
333334
rdoc (>= 4.0.0)
@@ -385,10 +386,11 @@ GEM
385386
net-smtp
386387
marcel (1.0.4)
387388
matrix (0.4.2)
389+
memflash (2.6.0)
390+
actionpack (>= 7.0)
388391
memory_profiler (1.1.0)
389392
method_source (1.1.0)
390393
mini_mime (1.1.5)
391-
mini_portile2 (2.8.9)
392394
minitest (5.25.5)
393395
monetize (1.12.0)
394396
money (~> 6.12)
@@ -408,7 +410,7 @@ GEM
408410
nenv (0.3.0)
409411
net-http-persistent (4.0.2)
410412
connection_pool (~> 2.2)
411-
net-imap (0.5.8)
413+
net-imap (0.5.9)
412414
date
413415
net-protocol
414416
net-pop (0.1.2)
@@ -417,16 +419,13 @@ GEM
417419
timeout
418420
net-smtp (0.5.1)
419421
net-protocol
420-
newrelic_rpm (9.16.0)
422+
newrelic_rpm (9.20.0)
421423
nio4r (2.7.4)
422-
nokogiri (1.18.8)
423-
mini_portile2 (~> 2.8.2)
424+
nokogiri (1.18.9-arm64-darwin)
424425
racc (~> 1.4)
425-
nokogiri (1.18.8-arm64-darwin)
426+
nokogiri (1.18.9-x86_64-darwin)
426427
racc (~> 1.4)
427-
nokogiri (1.18.8-x86_64-darwin)
428-
racc (~> 1.4)
429-
nokogiri (1.18.8-x86_64-linux-gnu)
428+
nokogiri (1.18.9-x86_64-linux-gnu)
430429
racc (~> 1.4)
431430
notiffany (0.1.3)
432431
nenv (~> 0.1)
@@ -512,8 +511,8 @@ GEM
512511
puma (6.6.0)
513512
nio4r (~> 2.0)
514513
racc (1.8.1)
515-
rack (3.1.16)
516-
rack-mini-profiler (4.0.0)
514+
rack (3.2.0)
515+
rack-mini-profiler (4.0.1)
517516
rack (>= 1.2.0)
518517
rack-protection (4.1.1)
519518
base64 (>= 0.1.0)
@@ -569,12 +568,12 @@ GEM
569568
rb-fsevent (0.11.2)
570569
rb-inotify (0.10.1)
571570
ffi (~> 1.0)
572-
rdoc (6.14.1)
571+
rdoc (6.14.2)
573572
erb
574573
psych (>= 4.0.0)
575-
recaptcha (5.19.0)
574+
recaptcha (5.20.1)
576575
regexp_parser (2.10.0)
577-
reline (0.6.1)
576+
reline (0.6.2)
578577
io-console (~> 0.5)
579578
request_store (1.7.0)
580579
rack (>= 1.4)
@@ -706,7 +705,7 @@ GEM
706705
activerecord (>= 7)
707706
terser (1.2.5)
708707
execjs (>= 0.3.0, < 3)
709-
thor (1.3.2)
708+
thor (1.4.0)
710709
tilt (2.2.0)
711710
timeout (0.4.3)
712711
ttfunk (1.7.0)
@@ -745,7 +744,6 @@ GEM
745744

746745
PLATFORMS
747746
arm64-darwin
748-
ruby
749747
x86_64-darwin
750748
x86_64-linux
751749
x86_64-linux-gnu
@@ -786,7 +784,7 @@ DEPENDENCIES
786784
geocoder
787785
guard-rspec
788786
icalendar
789-
importmap-rails (~> 2.1)
787+
importmap-rails (~> 2.2)
790788
jbuilder
791789
jwt
792790
kaminari
@@ -796,6 +794,7 @@ DEPENDENCIES
796794
lograge
797795
magic_test
798796
matrix
797+
memflash
799798
memory_profiler
800799
money-rails
801800
newrelic_rpm
@@ -843,4 +842,4 @@ DEPENDENCIES
843842
webmock (~> 3.25)
844843

845844
BUNDLED WITH
846-
2.6.9
845+
2.7.0

app/controllers/donations_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ def destroy
127127

128128
def load_form_collections
129129
@storage_locations = current_organization.storage_locations.active.alphabetized
130-
@donation_sites = current_organization.donation_sites.active.alphabetized
131130
@product_drives = current_organization.product_drives.alphabetized
132131
@product_drive_participants = current_organization.product_drive_participants.alphabetized
133132
@manufacturers = current_organization.manufacturers.alphabetized
134133
@items = current_organization.items.active.alphabetized
134+
# Return all active donation sites, or the donation site that was selected for the donation if it's inactive
135+
@donation_sites = current_organization.donation_sites.active.or(DonationSite.where(id: @donation.donation_site_id)).alphabetized
135136
end
136137

137138
def clean_donation_money_raised

app/controllers/product_drives_controller.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,18 @@ def update
8888
end
8989

9090
def destroy
91-
current_organization.product_drives.find(params[:id]).destroy
91+
product_drive = current_organization.product_drives.find(params[:id])
92+
success = product_drive.destroy
93+
9294
respond_to do |format|
93-
format.html { redirect_to product_drives_url, notice: 'Product drive was successfully destroyed.' }
94-
format.json { head :no_content }
95+
if success
96+
format.html { redirect_to product_drives_url, notice: 'Product drive was successfully destroyed.' }
97+
format.json { head :no_content }
98+
else
99+
error_message = product_drive.errors.full_messages.to_sentence
100+
format.html { redirect_to product_drive_path(product_drive), error: error_message }
101+
format.json { render json: {error: error_message}, status: :unprocessable_entity }
102+
end
95103
end
96104
end
97105

app/controllers/transfers_controller.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def index
2121

2222
def create
2323
@transfer = current_organization.transfers.new(transfer_params)
24+
@transfer.line_items.combine!
2425

2526
TransferCreateService.call(@transfer)
2627
redirect_to transfers_path, notice: "#{@transfer.line_items.total} items have been transferred from #{@transfer.from.name} to #{@transfer.to.name}!"
@@ -57,6 +58,18 @@ def destroy
5758
redirect_to transfers_path
5859
end
5960

61+
def validate
62+
@transfer = current_organization.transfers.new(transfer_params)
63+
@transfer.line_items.combine!
64+
65+
if @transfer.valid?
66+
body = render_to_string(partial: "transfers/validate_modal", formats: [:html], layout: false)
67+
render json: {valid: true, body: body}
68+
else
69+
render json: {valid: false}, status: :unprocessable_entity
70+
end
71+
end
72+
6073
private
6174

6275
def load_form_collections

app/models/product_drive.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ProductDrive < ApplicationRecord
3131
search_dates[:end_date])
3232
}
3333

34-
has_many :donations, dependent: :nullify
34+
has_many :donations, dependent: :restrict_with_error
3535
has_many :product_drive_participants, -> { distinct }, through: :donations
3636
validates :name, presence:
3737
{ message: "A name must be chosen." }

app/models/purchase.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class Purchase < ApplicationRecord
6060
validates :amount_spent_in_cents, numericality: { greater_than: 0 }
6161
validate :total_equal_to_all_categories
6262

63+
validates :amount_spent_on_diapers_cents, numericality: { greater_than_or_equal_to: 0 }
64+
validates :amount_spent_on_adult_incontinence_cents, numericality: { greater_than_or_equal_to: 0 }
65+
validates :amount_spent_on_period_supplies_cents, numericality: { greater_than_or_equal_to: 0 }
66+
validates :amount_spent_on_other_cents, numericality: { greater_than_or_equal_to: 0 }
67+
6368
SummaryByDates = Data.define(
6469
:amount_spent,
6570
:recent_purchases,

app/views/account_requests/new.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<div class='card-text' id='partner_info'>
2929
<p class='p-2'>Are you a current partner to diaper and/or period supply banks? If so please go <a href='https://humanessentials.app/users/sign_in'>here</a> to login.</p>
3030
<p class='p-2'>If you are wishing to receive diapers/period supplies and partner to a local diaper/period supply bank please contact your local bank. They are the only ones able create your account.</p>
31+
<p class='p-2'>If you are looking for an essentials bank that distributes diapers, please refer to the <a href='https://nationaldiaperbanknetwork.org/member-directory/'>NDBN member directory</a>. If you are, instead, looking for an essentials bank that deals in period supplies, please refer to the <a href='https://allianceforperiodsupplies.org/allied-programs/'>Alliance for Period Supplies directory</a>.</p>
3132
</div>
3233

3334
<div class='card-text' id='create_bank'>

app/views/partners/_form.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<% if doc.persisted? %>
5454
<li class="attached-document d-flex justify-content-between align-items-center p-2 border rounded mb-2" data-document-id="<%= doc.signed_id %>">
5555
<%= link_to doc.blob.filename.to_s, rails_blob_path(doc), class: "font-weight-bold w-75 text-truncate" %>
56+
<%= f.hidden_field :documents, multiple: true, value: doc.signed_id %>
5657
<%= delete_button_to attachment_path(doc), { text: "Remove", size: "md", confirm: "Are you sure you want to permanently remove this document?" } %>
5758
</li>
5859
<% end %>

app/views/shared/_flash.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<%= turbo_frame_tag "flash" do %>
2-
<% flash.each do |key, message| %>
2+
<% flash.keys.each do |key| %>
33
<div
44
class="<%= flash_class(key) %> alert-dismissible"
55
role="alert"
6-
style="white-space: pre-line;"><%= message %></div>
6+
style="white-space: pre-line;"><%= flash[key] %></div>
77
<% end %>
88
<% end %>

0 commit comments

Comments
 (0)