Skip to content

Commit 386e352

Browse files
authored
Merge branch 'main' into rluodev/4992-invoice-fix-state-management-migrate
2 parents c1a3e63 + c003bf0 commit 386e352

32 files changed

+738
-73
lines changed

Gemfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ gem "reverse_markdown" # public activity to discord
108108
gem "namae" # multi-cultural human name parser
109109
gem "premailer-rails" # css to inline styles for emails
110110
gem "safely_block"
111-
gem "strong_migrations", "~> 1" # protects against risky migrations
112-
# [@garyhtou] ^ We still use Postgres 11 in dev (not in prod). Strong Migrations
113-
# 2.x is incompatible with Postgres 11.
111+
gem "strong_migrations", "~> 2" # protects against risky migrations
114112
gem "xxhash" # fast hashing
115113
gem "memo_wise"
116114

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ GEM
129129
activerecord (>= 6.0.0)
130130
activesupport (>= 6.0.0)
131131
api-pagination (6.0.0)
132-
appsignal (4.5.4)
132+
appsignal (4.7.5)
133133
logger
134134
rack (>= 2.0.0)
135135
argon2-kdf (0.3.0)
@@ -825,8 +825,8 @@ GEM
825825
statsd-instrument (3.9.9)
826826
stringio (3.1.7)
827827
stripe (11.7.0)
828-
strong_migrations (1.8.0)
829-
activerecord (>= 5.2)
828+
strong_migrations (2.5.1)
829+
activerecord (>= 7.1)
830830
terser (1.2.6)
831831
execjs (>= 0.3.0, < 3)
832832
thor (1.4.0)
@@ -1030,7 +1030,7 @@ DEPENDENCIES
10301030
stackprof
10311031
statsd-instrument (~> 3.9)
10321032
stripe (= 11.7.0)
1033-
strong_migrations (~> 1)
1033+
strong_migrations (~> 2)
10341034
suo!
10351035
terser (~> 1.2)
10361036
turbo-rails (~> 2.0.17)
8.51 KB
Loading
6.15 KB
Loading

app/controllers/admin/base_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module Admin
44
class BaseController < ApplicationController
5+
include RedirectToUi3
6+
57
skip_after_action :verify_authorized # do not force pundit
68
before_action :signed_in_admin
79

app/controllers/api/v4/stripe_cards_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def card_designs
161161
set_api_event
162162
authorize @event, :create_stripe_card?, policy_class: EventPolicy
163163

164-
@designs = [event.stripe_card_personalization_designs&.available, StripeCard::PersonalizationDesign.common.available].flatten.compact
164+
@designs = [@event.stripe_card_personalization_designs&.available, StripeCard::PersonalizationDesign.common.available].flatten.compact
165165
else
166166
skip_authorization
167167
@designs = StripeCard::PersonalizationDesign.common.available

app/controllers/application_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
class ApplicationController < ActionController::Base
4+
include RedirectToUi3
5+
46
include Pundit::Authorization
57
include SessionsHelper
68
include ToursHelper

app/controllers/card_grants_controller.rb

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,33 @@ class CardGrantsController < ApplicationController
66
skip_before_action :signed_in_user, only: [:show, :spending]
77
skip_after_action :verify_authorized, only: [:show, :spending]
88

9-
before_action :set_event, only: %i[new create]
10-
before_action :set_card_grant, except: %i[new create]
9+
before_action :set_event, only: [:new, :create, :index, :card_index, :transaction_index]
10+
before_action :set_card_grant, except: [:new, :create, :index, :card_index, :transaction_index]
11+
12+
def index
13+
authorize @event, :card_grant_overview?
14+
end
15+
16+
def card_index
17+
authorize @event, :card_grant_overview?
18+
19+
card_grants_page = (params[:page] || 1).to_i
20+
card_grants_per_page = (params[:per] || 20).to_i
21+
22+
@card_grants = @event.card_grants.includes(:disbursement, :user, :stripe_card).order(created_at: :desc)
23+
@paginated_card_grants = @card_grants.page(card_grants_page).per(card_grants_per_page)
24+
end
25+
26+
def transaction_index
27+
authorize @event, :card_grant_overview?
28+
29+
transactions_page = (params[:page] || 1).to_i
30+
transactions_per_page = (params[:per] || 20).to_i
31+
32+
@all_stripe_cards = @event.stripe_cards.where.associated(:card_grant)
33+
@hcb_codes = HcbCode.where(hcb_code: @all_stripe_cards.flat_map(&:all_hcb_codes)).order(created_at: :desc)
34+
@paginated_hcb_codes = @hcb_codes.page(transactions_page).per(transactions_per_page)
35+
end
1136

1237
def new
1338
@card_grant = @event.card_grants.build(email: params[:email])
@@ -49,7 +74,7 @@ def create
4974
end
5075

5176
flash[:success] = "Successfully sent a grant to #{@card_grant.email}!"
52-
redirect_to event_transfers_path(@event)
77+
redirect_back_or_to event_transfers_path(@event)
5378
end
5479

5580
def edit_overview
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
module RedirectToUi3
4+
extend ActiveSupport::Concern
5+
6+
included do
7+
before_action :redirect_to_ui3_if_needed
8+
end
9+
10+
private
11+
12+
def redirect_to_ui3_if_needed
13+
return if current_user.nil?
14+
15+
# return unless request.get? || request.head?
16+
17+
if Flipper.enabled?(:redirect_to_ui3_2025_11_03, current_user) && request.host == "hcb.hackclub.com"
18+
redirect_to "https://ui3.hcb.hackclub.com#{request.fullpath}", allow_other_host: true
19+
end
20+
end
21+
end

app/controllers/events_controller.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,20 +1344,21 @@ def show_running_balance?
13441344
end
13451345

13461346
def set_cacheable
1347-
return false unless params[:q].blank? &&
1348-
params[:page].blank? &&
1349-
params[:per].blank? &&
1350-
@user.nil? &&
1351-
@tag.blank? &&
1352-
@type.blank? &&
1353-
@start_date.blank? &&
1354-
@end_date.blank? &&
1355-
@minimum_amount.nil? &&
1356-
@maximum_amount.nil? &&
1357-
!@missing_receipts
1358-
return false if organizer_signed_in?
1359-
1360-
true
1347+
has_filters = !(
1348+
params[:q].blank? &&
1349+
params[:page].blank? &&
1350+
params[:per].blank? &&
1351+
@user.nil? &&
1352+
@tag.blank? &&
1353+
@type.blank? &&
1354+
@start_date.blank? &&
1355+
@end_date.blank? &&
1356+
@minimum_amount.nil? &&
1357+
@maximum_amount.nil? &&
1358+
!@missing_receipts
1359+
)
1360+
1361+
@cacheable = !(organizer_signed_in? || has_filters)
13611362
end
13621363

13631364
def set_mock_data

0 commit comments

Comments
 (0)