Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion app/controllers/card_grants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def new

def create
params[:card_grant][:amount_cents] = Monetize.parse(params[:card_grant][:amount_cents]).cents
@card_grant = @event.card_grants.build(params.require(:card_grant).permit(:amount_cents, :email, :invite_message, :keyword_lock, :purpose, :one_time_use, :pre_authorization_required, :instructions).merge(sent_by: current_user))
@card_grant = @event.card_grants.build(params.require(:card_grant).permit(:amount_cents, :email, :invite_message, :keyword_lock, :purpose, :one_time_use, :pre_authorization_required, :instructions).merge(sent_by: current_user, expiration_date: @event.card_grant_setting&.expiration_preference_before_type_cast&.days&.from_now || 365.days.from_now))

authorize @card_grant

Expand Down
12 changes: 12 additions & 0 deletions app/jobs/one_time_jobs/backfill_grant_expiration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module OneTimeJobs
class BackfillGrantExpiration
def self.perform
CardGrant.find_each do |cg|
cg.update(expiration_date: cg.created_at + (cg.event.card_grant_setting&.expiration_preference_before_type_cast&.days || 365.days))
end
end

end
end
1 change: 1 addition & 0 deletions app/models/card_grant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# banned_merchants :string
# category_lock :string
# email :string not null
# expiration_date :datetime
# instructions :text
# invite_message :string
# keyword_lock :string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddExpirationDateToCardGrants < ActiveRecord::Migration[8.0]
def change
add_column :card_grants, :expiration_date, :datetime
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 2025_11_23_092317) do
ActiveRecord::Schema[8.0].define(version: 2025_12_02_231531) do
create_schema "google_sheets"

# These are extensions that must be enabled in order to support this database
Expand Down Expand Up @@ -477,6 +477,7 @@
t.bigint "disbursement_id"
t.string "email", null: false
t.bigint "event_id", null: false
t.datetime "expiration_date"
t.text "instructions"
t.string "invite_message"
t.string "keyword_lock"
Expand Down