Skip to content

Commit cbaf037

Browse files
authored
Merge branch 'main' into 5103-Catch-bad-date-ranges
2 parents b7e246b + d8fa236 commit cbaf037

154 files changed

Lines changed: 1577 additions & 871 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,4 @@ package-lock.json
8888
out/
8989

9090
.vscode/
91+
.aider*

Gemfile.lock

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
Ascii85 (1.1.1)
4+
Ascii85 (2.0.1)
55
actioncable (8.0.1)
66
actionpack (= 8.0.1)
77
activesupport (= 8.0.1)
@@ -77,7 +77,7 @@ GEM
7777
public_suffix (>= 2.0.2, < 7.0)
7878
afm (0.2.2)
7979
annotaterb (4.14.0)
80-
ast (2.4.2)
80+
ast (2.4.3)
8181
autoprefixer-rails (10.4.13.0)
8282
execjs (~> 2)
8383
awesome_print (1.9.2)
@@ -191,7 +191,7 @@ GEM
191191
railties (>= 4.1.0)
192192
responders
193193
warden (~> 1.2.3)
194-
devise_invitable (2.0.9)
194+
devise_invitable (2.0.10)
195195
actionmailer (>= 5.0)
196196
devise (>= 4.6)
197197
diff-lcs (1.5.1)
@@ -222,7 +222,7 @@ GEM
222222
dry-inflector (~> 1.0)
223223
dry-logic (~> 1.4)
224224
zeitwerk (~> 2.6)
225-
erb_lint (0.7.0)
225+
erb_lint (0.9.0)
226226
activesupport
227227
better_html (>= 2.0.1)
228228
parser (>= 2.7.1.4)
@@ -273,18 +273,18 @@ GEM
273273
ffi (1.17.0-x86_64-darwin)
274274
ffi (1.17.0-x86_64-linux-gnu)
275275
filterrific (5.2.7)
276-
flipper (1.3.2)
276+
flipper (1.3.4)
277277
concurrent-ruby (< 2)
278-
flipper-active_record (1.3.2)
278+
flipper-active_record (1.3.4)
279279
activerecord (>= 4.2, < 9)
280-
flipper (~> 1.3.2)
281-
flipper-ui (1.3.2)
280+
flipper (~> 1.3.4)
281+
flipper-ui (1.3.4)
282282
erubi (>= 1.0.0, < 2.0.0)
283-
flipper (~> 1.3.2)
283+
flipper (~> 1.3.4)
284284
rack (>= 1.4, < 4)
285285
rack-protection (>= 1.5.3, < 5.0.0)
286286
rack-session (>= 1.0.2, < 3.0.0)
287-
sanitize (< 7)
287+
sanitize (< 8)
288288
foreman (0.88.1)
289289
formatador (1.1.0)
290290
geocoder (1.8.5)
@@ -329,7 +329,7 @@ GEM
329329
actionview (>= 5.0.0)
330330
activesupport (>= 5.0.0)
331331
jmespath (1.6.2)
332-
json (2.9.1)
332+
json (2.10.2)
333333
jwt (2.9.1)
334334
base64
335335
kaminari (1.2.2)
@@ -344,7 +344,7 @@ GEM
344344
activerecord
345345
kaminari-core (= 1.2.2)
346346
kaminari-core (1.2.2)
347-
knapsack_pro (7.13.1)
347+
knapsack_pro (8.1.0)
348348
rake
349349
language_server-protocol (3.17.0.4)
350350
launchy (3.0.0)
@@ -356,7 +356,7 @@ GEM
356356
listen (3.9.0)
357357
rb-fsevent (~> 0.10, >= 0.10.3)
358358
rb-inotify (~> 0.9, >= 0.9.10)
359-
logger (1.6.6)
359+
logger (1.7.0)
360360
lograge (0.14.0)
361361
actionpack (>= 4)
362362
activesupport (>= 4)
@@ -382,7 +382,7 @@ GEM
382382
method_source (1.1.0)
383383
mini_mime (1.1.5)
384384
mini_portile2 (2.8.8)
385-
minitest (5.25.4)
385+
minitest (5.25.5)
386386
monetize (1.12.0)
387387
money (~> 6.12)
388388
money (6.16.0)
@@ -412,14 +412,14 @@ GEM
412412
net-protocol
413413
newrelic_rpm (9.16.0)
414414
nio4r (2.7.4)
415-
nokogiri (1.18.3)
415+
nokogiri (1.18.7)
416416
mini_portile2 (~> 2.8.2)
417417
racc (~> 1.4)
418-
nokogiri (1.18.3-arm64-darwin)
418+
nokogiri (1.18.7-arm64-darwin)
419419
racc (~> 1.4)
420-
nokogiri (1.18.3-x86_64-darwin)
420+
nokogiri (1.18.7-x86_64-darwin)
421421
racc (~> 1.4)
422-
nokogiri (1.18.3-x86_64-linux-gnu)
422+
nokogiri (1.18.7-x86_64-linux-gnu)
423423
racc (~> 1.4)
424424
notiffany (0.1.3)
425425
nenv (~> 0.1)
@@ -455,12 +455,12 @@ GEM
455455
activerecord (>= 6.1)
456456
request_store (~> 1.4)
457457
parallel (1.26.3)
458-
parser (3.3.7.0)
458+
parser (3.3.7.4)
459459
ast (~> 2.4.1)
460460
racc
461461
pdf-core (0.10.0)
462-
pdf-reader (2.12.0)
463-
Ascii85 (~> 1.0)
462+
pdf-reader (2.14.1)
463+
Ascii85 (>= 1.0, < 3.0, != 2.0.0)
464464
afm (~> 0.2.1)
465465
hashery (~> 2.0)
466466
ruby-rc4
@@ -481,6 +481,7 @@ GEM
481481
prawn-table (0.2.2)
482482
prawn (>= 1.3.0, < 3.0.0)
483483
prettyprint (0.2.0)
484+
prism (1.4.0)
484485
pry (0.14.2)
485486
coderay (~> 1.1)
486487
method_source (~> 1.0)
@@ -504,7 +505,7 @@ GEM
504505
puma (6.6.0)
505506
nio4r (~> 2.0)
506507
racc (1.8.1)
507-
rack (3.1.10)
508+
rack (3.1.12)
508509
rack-mini-profiler (3.3.1)
509510
rack (>= 1.2.0)
510511
rack-protection (4.0.0)
@@ -560,7 +561,7 @@ GEM
560561
rb-fsevent (0.11.2)
561562
rb-inotify (0.10.1)
562563
ffi (~> 1.0)
563-
rdoc (6.12.0)
564+
rdoc (6.13.1)
564565
psych (>= 4.0.0)
565566
recaptcha (5.19.0)
566567
regexp_parser (2.10.0)
@@ -605,8 +606,9 @@ GEM
605606
rubocop-ast (>= 1.36.2, < 2.0)
606607
ruby-progressbar (~> 1.7)
607608
unicode-display_width (>= 2.4.0, < 4.0)
608-
rubocop-ast (1.38.0)
609-
parser (>= 3.3.1.0)
609+
rubocop-ast (1.43.0)
610+
parser (>= 3.3.7.2)
611+
prism (~> 1.4)
610612
rubocop-performance (1.23.1)
611613
rubocop (>= 1.48.1, < 2.0)
612614
rubocop-ast (>= 1.31.1, < 2.0)
@@ -620,9 +622,9 @@ GEM
620622
ruby-progressbar (1.13.0)
621623
ruby-rc4 (0.1.5)
622624
ruby2_keywords (0.0.5)
623-
sanitize (6.1.3)
625+
sanitize (7.0.0)
624626
crass (~> 1.0.2)
625-
nokogiri (>= 1.12.0)
627+
nokogiri (>= 1.16.8)
626628
sass-rails (6.0.0)
627629
sassc-rails (~> 2.1, >= 2.1.1)
628630
sassc (2.4.0)
@@ -657,7 +659,7 @@ GEM
657659
snaky_hash (2.0.1)
658660
hashie
659661
version_gem (~> 1.1, >= 1.1.1)
660-
solid_cache (1.0.6)
662+
solid_cache (1.0.7)
661663
activejob (>= 7.2)
662664
activerecord (>= 7.2)
663665
railties (>= 7.2)
@@ -686,8 +688,8 @@ GEM
686688
rubocop-rails (~> 2.25.0)
687689
stimulus-rails (1.3.4)
688690
railties (>= 6.0.0)
689-
stringio (3.1.2)
690-
strong_migrations (2.2.0)
691+
stringio (3.1.6)
692+
strong_migrations (2.2.1)
691693
activerecord (>= 7)
692694
terser (1.2.5)
693695
execjs (>= 0.3.0, < 3)
@@ -696,9 +698,9 @@ GEM
696698
timeout (0.4.3)
697699
ttfunk (1.8.0)
698700
bigdecimal (~> 3.1)
699-
turbo-rails (2.0.10)
700-
actionpack (>= 6.0.0)
701-
railties (>= 6.0.0)
701+
turbo-rails (2.0.13)
702+
actionpack (>= 7.1.0)
703+
railties (>= 7.1.0)
702704
tzinfo (2.0.6)
703705
concurrent-ruby (~> 1.0)
704706
unicode-display_width (3.1.4)
@@ -831,4 +833,4 @@ DEPENDENCIES
831833
webmock (~> 3.24)
832834

833835
BUNDLED WITH
834-
2.6.5
836+
2.6.6

app/assets/stylesheets/simple_form-bootstrap/_form_multi_select.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@
1616
margin-left: 0 !important;
1717
margin-right: 0 !important;
1818
}
19-
}
19+
}
20+
21+
.input-group, .form-group {
22+
select {
23+
@extend .form-select;
24+
}
25+
}

app/controllers/admin/users_controller.rb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# [Super Admin] This is for administrating users at a global level. We can create, view, modify, etc.
22
class Admin::UsersController < AdminController
3-
before_action :load_organizations, only: %i[new create edit update]
3+
before_action :load_organizations, only: %i[create edit update]
44
before_action :user_params, only: %i[create update]
55

66
def index
@@ -34,15 +34,19 @@ def new
3434

3535
def edit
3636
@user = User.find_by(id: params[:id])
37-
@resources = Role.resources_for_select
3837
end
3938

4039
def create
4140
@user = User.new(user_params)
42-
UserInviteService.invite(name: user_params[:name],
41+
validate_role_resource_params
42+
klass = Role::TITLE_TO_RESOURCE[params[:resource_type].to_sym]
43+
resource = klass&.find(params[:resource_id])
44+
UserInviteService.invite(
45+
name: user_params[:name],
4346
email: user_params[:email],
44-
roles: [Role::ORG_USER],
45-
resource: Organization.find(organization_id_param))
47+
roles: [params[:resource_type].to_sym],
48+
resource: resource
49+
)
4650
flash[:notice] = "Created a new user!"
4751
redirect_to admin_users_path
4852
rescue => e
@@ -95,12 +99,9 @@ def user_params
9599
params.require(:user).permit(:name, :email)
96100
end
97101

98-
def organization_id_param
99-
organization_id = params[:user][:organization_id]
100-
101-
raise "Please select an organization for the user." if organization_id.blank?
102-
103-
organization_id
102+
def validate_role_resource_params
103+
raise "Please select a role for the user." if params[:resource_type].blank?
104+
raise "Please select an associated resource for the role." if !Role::ROLES_WITHOUT_RESOURCE.map(&:to_s).include?(params[:resource_type]) && params[:resource_id].blank?
104105
end
105106

106107
def load_organizations

app/controllers/concerns/importable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Importable
2525
def import_csv
2626
if params[:file].present?
2727
data = File.read(params[:file].path, encoding: "BOM|UTF-8")
28-
csv = CSV.parse(data, headers: true).reject { |row| row.to_hash.values.any?(&:nil?) }
28+
csv = CSV.parse(data, headers: true)
2929
if csv.count.positive? && csv.first.headers.all? { |header| !header.nil? }
3030
errors = resource_model.import_csv(csv, current_organization.id)
3131
if errors.empty?

app/controllers/donations_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def index
3333
@donations_quantity = @donations.collect(&:total_quantity).sum
3434
@paginated_donations_quantity = @paginated_donations.collect(&:total_quantity).sum
3535
@total_value_all_donations = total_value(@donations)
36+
@paginated_in_kind_value = total_value(@paginated_donations)
3637
@total_money_raised = total_money_raised(@donations)
3738
@storage_locations = @donations.filter_map { |donation| donation.storage_location if !donation.storage_location.discarded_at }.compact.uniq.sort
3839
@selected_storage_location = filter_params[:at_storage_location]

app/controllers/organizations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def organization_params
9494
params.require(:organization).permit(
9595
:name, :short_name, :street, :city, :state,
9696
:zipcode, :email, :url, :logo, :intake_location,
97-
:default_storage_location, :default_email_text,
97+
:default_storage_location, :default_email_text, :reminder_email_text,
9898
:invitation_text, :reminder_day, :deadline_day,
9999
:repackage_essentials, :distribute_monthly,
100100
:ndbn_member_id, :enable_child_based_requests,

app/controllers/partner_users_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def create
2424
@users = @partner.users
2525
render :index
2626
end
27+
rescue => e
28+
flash[:error] = e.message
29+
redirect_to partner_users_path(@partner)
2730
end
2831

2932
def destroy

app/controllers/partners/requests_controller.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ def fetch_items
8181
@requestable_items = PartnerFetchRequestableItemsService.new(partner_id: partner.id).call
8282
if Flipper.enabled?(:enable_packs)
8383
# hash of (item ID => hash of (request unit name => request unit plural name))
84-
@item_units = Item.where(id: @requestable_items.to_h.values).to_h do |i|
85-
[i.id, i.request_units.to_h { |u| [u.name, u.name.pluralize] }]
84+
item_ids = @requestable_items.to_h.values
85+
if item_ids.present?
86+
@item_units = Item.where(id: item_ids).to_h do |i|
87+
[i.id, i.request_units.to_h { |u| [u.name, u.name.pluralize] }]
88+
end
8689
end
8790
end
8891
end

app/controllers/vendors_controller.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ def reactivate
8888
redirect_to vendors_path, notice: "#{vendor.business_name} has been reactivated."
8989
end
9090

91+
def destroy
92+
vendor = current_organization.vendors.find(params[:id])
93+
vendor.destroy
94+
if vendor.errors.any?
95+
errors = vendor.errors.full_messages.join("\n")
96+
redirect_to vendors_path, error: "#{vendor.business_name} could not be removed. \n#{errors}"
97+
return
98+
end
99+
100+
redirect_to vendors_path, notice: "#{vendor.business_name} has been removed."
101+
end
102+
91103
private
92104

93105
def vendor_params

0 commit comments

Comments
 (0)