Skip to content

Commit

Permalink
replace class variables with constants in recurring donation model (b…
Browse files Browse the repository at this point in the history
…ad practice to use class variables)
  • Loading branch information
winsonwan committed Apr 28, 2024
1 parent 24a6bd0 commit d0f138a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def process_donation
# Given valid donation, customer, and charge token, create & place credit card order.
@gOrderInProgress = Order.new_from_donation(@amount, @account_code, @customer)
case params[:donation_frequency]
when Donation.recurring_donation
when Donation::RECURRING_DONATION
@gOrderInProgress.add_recurring_donation()
end
@gOrderInProgress.purchasemethod = Purchasemethod.get_type_by_name('web_cc')
Expand Down
8 changes: 4 additions & 4 deletions app/models/items/donation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
class Donation < Item

# only possible donation frequencies (either one-time, or recurring at the specified interval)
@@one_time_donation = 'One Time'
@@recurring_donation = 'Monthly'
cattr_reader :one_time_donation
cattr_reader :recurring_donation
ONE_TIME_DONATION = 'One Time'
RECURRING_DONATION = 'Monthly'
# cattr_reader :one_time_donation
# cattr_reader :recurring_donation

def self.default_code
AccountCode.find(Option.default_donation_account_code)
Expand Down
8 changes: 4 additions & 4 deletions app/views/options/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
= option_description_for(:default_donation_type)
.col-md-8{id:"donation_type_radio"}
.radio-group.form-inline
= f.radio_button :default_donation_frequency, Donation.one_time_donation, :class => 'form-control', :id => Donation.one_time_donation
= f.label :default_donation_frequency, Donation.one_time_donation, :class => 'form-control', :for => Donation.one_time_donation
= f.radio_button :default_donation_frequency, Donation.recurring_donation, :class => 'form-control', :id => Donation.recurring_donation
= f.label :default_donation_frequency, Donation.recurring_donation, :class => 'form-control', :for => Donation.recurring_donation
= f.radio_button :default_donation_frequency, Donation::ONE_TIME_DONATION, :class => 'form-control', :id => Donation::ONE_TIME_DONATION
= f.label :default_donation_frequency, Donation::ONE_TIME_DONATION, :class => 'form-control', :for => Donation::ONE_TIME_DONATION
= f.radio_button :default_donation_frequency, Donation::RECURRING_DONATION, :class => 'form-control', :id => Donation::RECURRING_DONATION
= f.label :default_donation_frequency, Donation::RECURRING_DONATION, :class => 'form-control', :for => Donation::RECURRING_DONATION
= render_collection_of_options f, %w( |
recurring_donation_contact_emails |
notify_theater_about_new_recurring_donation |
Expand Down
8 changes: 4 additions & 4 deletions app/views/store/donate.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
.form-group.form-row{id:"donation_frequency_radio"}
%label.col-form-label.text-right.col-sm-6{:for => :donation} Donation frequency
.radio-group.col-sm-6.col-md-2.form-inline
= radio_button_tag :donation_frequency, Donation.one_time_donation, Option.default_donation_frequency == Donation.one_time_donation, class: 'form-control', id: Donation.one_time_donation
= label_tag :donation_frequency, Donation.one_time_donation, class: 'form-control', for: Donation.one_time_donation
= radio_button_tag :donation_frequency, Donation.recurring_donation, Option.default_donation_frequency == Donation.recurring_donation, class: 'form-control', id: Donation.recurring_donation
= label_tag :donation_frequency, Donation.recurring_donation, class: 'form-control', for: Donation.recurring_donation
= radio_button_tag :donation_frequency, Donation::ONE_TIME_DONATION, Option.default_donation_frequency == Donation::ONE_TIME_DONATION, class: 'form-control', id: Donation::ONE_TIME_DONATION
= label_tag :donation_frequency, Donation::ONE_TIME_DONATION, class: 'form-control', for: Donation::ONE_TIME_DONATION
= radio_button_tag :donation_frequency, Donation::RECURRING_DONATION, Option.default_donation_frequency == Donation::RECURRING_DONATION, class: 'form-control', id: Donation::RECURRING_DONATION
= label_tag :donation_frequency, Donation::RECURRING_DONATION, class: 'form-control', for: Donation::RECURRING_DONATION
.form-group.form-row
%label.col-form-label{:for => :donation_comments}
If you'd like to be recognized as Anonymous, or if you'd like to donate in honor
Expand Down

0 comments on commit d0f138a

Please sign in to comment.