From d0f138a7ac68faa6549137386c2b69a308b2e60f Mon Sep 17 00:00:00 2001 From: Winson Wan Date: Sun, 28 Apr 2024 04:20:41 -0700 Subject: [PATCH] replace class variables with constants in recurring donation model (bad practice to use class variables) --- app/controllers/store_controller.rb | 2 +- app/models/items/donation.rb | 8 ++++---- app/views/options/index.html.haml | 8 ++++---- app/views/store/donate.html.haml | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/controllers/store_controller.rb b/app/controllers/store_controller.rb index 04ed30b1..d792a923 100644 --- a/app/controllers/store_controller.rb +++ b/app/controllers/store_controller.rb @@ -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') diff --git a/app/models/items/donation.rb b/app/models/items/donation.rb index 6657185a..73971ea2 100644 --- a/app/models/items/donation.rb +++ b/app/models/items/donation.rb @@ -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) diff --git a/app/views/options/index.html.haml b/app/views/options/index.html.haml index ec731cdd..578321b0 100644 --- a/app/views/options/index.html.haml +++ b/app/views/options/index.html.haml @@ -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 | diff --git a/app/views/store/donate.html.haml b/app/views/store/donate.html.haml index bf2fa12a..e7e226ec 100644 --- a/app/views/store/donate.html.haml +++ b/app/views/store/donate.html.haml @@ -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