From 15788b6bf85728381e840ac10597069a9b3354ff Mon Sep 17 00:00:00 2001 From: Winson Wan Date: Wed, 13 Mar 2024 11:05:42 -0700 Subject: [PATCH] delete remnants of recurring donation feature from this branch --- app/assets/javascripts/recurring_donations.js | 2 - .../stylesheets/recurring_donations.scss | 3 - app/controllers/options_controller.rb | 4 +- .../recurring_donations_controller.rb | 2 - app/controllers/store_controller.rb | 7 --- app/helpers/recurring_donations_helper.rb | 2 - app/models/items/donation.rb | 8 +-- app/models/recurring_donation.rb | 16 ----- app/views/options/index.html.haml | 32 ---------- app/views/store/donate.html.haml | 8 --- config/locales/en.option_descriptions.yml | 23 ------- config/routes.rb | 6 +- ...rring_donation_options_to_options_table.rb | 9 --- ...240229121243_create_recurring_donations.rb | 13 ---- db/schema.rb | 39 ++++-------- .../recurring_donations_controller_spec.rb | 5 -- spec/controllers/store_controller_spec.rb | 60 ------------------- spec/factories/recurring_donations.rb | 5 -- .../recurring_donations_helper_spec.rb | 15 ----- spec/models/recurring_donation_spec.rb | 5 -- 20 files changed, 19 insertions(+), 245 deletions(-) delete mode 100644 app/assets/javascripts/recurring_donations.js delete mode 100644 app/assets/stylesheets/recurring_donations.scss delete mode 100644 app/controllers/recurring_donations_controller.rb delete mode 100644 app/helpers/recurring_donations_helper.rb delete mode 100644 app/models/recurring_donation.rb delete mode 100644 db/migrate/20240225093946_add_recurring_donation_options_to_options_table.rb delete mode 100644 db/migrate/20240229121243_create_recurring_donations.rb delete mode 100644 spec/controllers/recurring_donations_controller_spec.rb delete mode 100644 spec/factories/recurring_donations.rb delete mode 100644 spec/helpers/recurring_donations_helper_spec.rb delete mode 100644 spec/models/recurring_donation_spec.rb diff --git a/app/assets/javascripts/recurring_donations.js b/app/assets/javascripts/recurring_donations.js deleted file mode 100644 index dee720fac..000000000 --- a/app/assets/javascripts/recurring_donations.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place all the behaviors and hooks related to the matching controller here. -// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/recurring_donations.scss b/app/assets/stylesheets/recurring_donations.scss deleted file mode 100644 index 7f2ad587d..000000000 --- a/app/assets/stylesheets/recurring_donations.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the recurring_donations controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/options_controller.rb b/app/controllers/options_controller.rb index c5ccf02b9..5458c61cd 100644 --- a/app/controllers/options_controller.rb +++ b/app/controllers/options_controller.rb @@ -1,7 +1,7 @@ class OptionsController < ApplicationController before_filter :is_admin_filter - + def index @o = Option.first end @@ -15,8 +15,6 @@ def update option_params['advance_sales_cutoff'].to_i * params['before_or_after'].to_i # if there is a file upload for HTML template, get it option_params['html_email_template'] = params['html_email_template'].read unless params['html_email_template'].blank? - # if recurring donations not allowed, set default_donation_type to one time - option_params['default_donation_type'] = 'one' unless option_params['allow_recurring_donations'] == 'true' if (@o.update_attributes(option_params)) redirect_to options_path, :notice => "Update successful." else diff --git a/app/controllers/recurring_donations_controller.rb b/app/controllers/recurring_donations_controller.rb deleted file mode 100644 index fd98e442e..000000000 --- a/app/controllers/recurring_donations_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class RecurringDonationsController < ApplicationController -end diff --git a/app/controllers/store_controller.rb b/app/controllers/store_controller.rb index b3bac21cc..50063c238 100644 --- a/app/controllers/store_controller.rb +++ b/app/controllers/store_controller.rb @@ -156,19 +156,12 @@ def process_donation @gOrderInProgress.processed_by = @customer @gOrderInProgress.comments = params[:comments].to_s @gOrderInProgress.ready_for_purchase? or return redirect_to(redirect_route, :alert => @gOrderInProgress.errors.as_html) - # if customer checks 'monthly' donation radio button, then create (and save) a new recurring donation instance - if params[:donation_frequency] == 'monthly' - @recurring_donation = RecurringDonation.from_order_w_first_donation_and_save(@gOrderInProgress) - @gOrderInProgress.donation.recurring_donation_id = @recurring_donation.id - end if finalize_order(@gOrderInProgress, send_email_confirmation: @gOrderInProgress.purchaser.valid_email_address?) # forget customer after successful guest checkout @guest_checkout = true logout_keeping_session! render :action => 'place_order' else - # if order fails to finalize, destroy recurring donation row - @recurring_donation.destroy if @recurring_donation redirect_to redirect_route, :alert => @gOrderInProgress.errors.as_html end end diff --git a/app/helpers/recurring_donations_helper.rb b/app/helpers/recurring_donations_helper.rb deleted file mode 100644 index e983f9fd8..000000000 --- a/app/helpers/recurring_donations_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module RecurringDonationsHelper -end diff --git a/app/models/items/donation.rb b/app/models/items/donation.rb index be772334d..de350c3c3 100644 --- a/app/models/items/donation.rb +++ b/app/models/items/donation.rb @@ -6,15 +6,13 @@ class Donation < Item def self.default_code AccountCode.find(Option.default_donation_account_code) end - + belongs_to :account_code validates_associated :account_code validates_presence_of :account_code_id - + belongs_to :customer - - belongs_to :recurring_donation - + validates_numericality_of :amount validates_inclusion_of :amount, :in => 1..10_000_000, :message => "must be at least 1 dollar" diff --git a/app/models/recurring_donation.rb b/app/models/recurring_donation.rb deleted file mode 100644 index 8a253539c..000000000 --- a/app/models/recurring_donation.rb +++ /dev/null @@ -1,16 +0,0 @@ -class RecurringDonation < ActiveRecord::Base - - belongs_to :account_code - belongs_to :customer - has_many :donations - - def self.from_order_w_first_donation_and_save(order) - @recurring_donation = RecurringDonation.create!( - account_code_id: order.donation.account_code_id, - customer_id: order.customer_id, - amount: order.donation.amount, - comments: order.donation.comments) - @recurring_donation - end - -end diff --git a/app/views/options/index.html.haml b/app/views/options/index.html.haml index 9ce51fbcf..e334fa049 100644 --- a/app/views/options/index.html.haml +++ b/app/views/options/index.html.haml @@ -1,14 +1,3 @@ -:javascript - // Hide default donation type radio group unless recurring donations are allowed - function showDefaultDonation(select_allow_recurring_donations) { - var row = document.getElementById('default_donation_type_form_row'); - if (select_allow_recurring_donations.value == 'true') { - row.style.visibility = 'visible'; - } else { - row.style.visibility = 'hidden'; - } - } - = form_for @o, :html => {:multipart => true, :id => 'edit_options_form'} do |f| .card.my-1 .card-header.h3 Your Venue Contact Info @@ -52,27 +41,6 @@ quick_donation_redirect | donation_ack_from | ) | - .form-row - .col-md-4.text-right - %label.col-form-label Allow Monthly Recurring Donations - = option_description_for(:allow_recurring_donations) - .col-md-8 - = f.select :allow_recurring_donations, [['Yes', true], ['No', false]], {}, {:class => 'form-control', onchange: 'showDefaultDonation(this)'} - .form-row{id:"default_donation_type_form_row", style:"visibility: #{@o.allow_recurring_donations ? 'visible' : 'hidden'}"} - .col-md-4.text-right - %label.col-form-label Default Donation Type - = option_description_for(:default_donation_type) - .col-md-8 - .radio-group.form-inline - = f.radio_button :default_donation_type, 'one', :class => 'form-control', :id => 'one' - = f.label :default_donation_type, 'One Time', :class => 'form-control', :for => 'one' - = f.radio_button :default_donation_type, 'monthly', :class => 'form-control', :id => 'monthly' - = f.label :default_donation_type, 'Monthly', :class => 'form-control', :for => 'monthly' - = render_collection_of_options f, %w( | - recurring_donation_contact_emails | - notify_theatre_about_new_recurring_donation | - notify_threate_about_failed_recurring_donation_charge | - ) | .card.my-1 .card-header.h3 Customer Account diff --git a/app/views/store/donate.html.haml b/app/views/store/donate.html.haml index f1d0871af..968dc2dae 100644 --- a/app/views/store/donate.html.haml +++ b/app/views/store/donate.html.haml @@ -43,14 +43,6 @@ = text_field_tag 'donation', @amount, :type => :number, :class => 'text-right form-control form-control-sm' .input-group-append %span.input-group-text.form-control-sm .00 - - if Option.allow_recurring_donations - .form-group.form-row - %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', 'one', Option.default_donation_type == 'one', class: 'form-control', id: 'one' - = label_tag 'donation_type_one_time', 'One Time', class: 'form-control', for: 'one' - = radio_button_tag 'donation_frequency', 'monthly', Option.default_donation_type == 'monthly', class: 'form-control', id: 'monthly' - = label_tag 'donation_type_monthly', 'Monthly', class: 'form-control', for: 'monthly' .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 diff --git a/config/locales/en.option_descriptions.yml b/config/locales/en.option_descriptions.yml index 8a82babc5..8ca03f8ca 100644 --- a/config/locales/en.option_descriptions.yml +++ b/config/locales/en.option_descriptions.yml @@ -484,26 +484,3 @@ en: https. NOTE: Audience1st will also try to serve your favicon.ico from the same directory that contains the stylesheet; if no favicon.ico is found there, a generic one will be served. - - allow_recurring_donations: > - - Whether to allow customers to initiate recurring monthly donations. - - default_donation_type: > - - Default donation type to be checked when a customer is on the 'make donation' page. - - recurring_donation_contact_emails: > - - Comma-separated list of theatre contact email addresses to contact - regarding recurring donation activity. - - notify_theatre_about_new_recurring_donation: > - - Whether to notify theatre contact email addresses when a customer initiates - a new recurring donation. - - notify_threate_about_failed_recurring_donation_charge: > - - Whether to notify theatre contact email addresses when a charge from an - existing recurring donation fails. \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 553d7f8a0..522344c7c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,7 @@ resources :account_codes, :except => :show resources :ticket_sales_imports, :except => [:new] resources :labels, :only => [:index, :create, :update, :destroy] - resources :seatmaps, :except => [:new] + resources :seatmaps, :except => [:new] resources :seating_zones, :only => [:index, :create, :destroy] resources :customers, :except => :destroy do @@ -75,7 +75,7 @@ resources :shows, :except => [:show] do resources :showdates, :except => [:index] end - + resources :valid_vouchers, :except => [:index] resources :vouchertypes do member do @@ -129,7 +129,7 @@ # quick-donation neither requires nor sets customer-id: - get 'donate(/:customer_id)' => 'store#donate', :as => 'quick_donate' + get '/donate/(:customer_id)' => 'store#donate', :as => 'quick_donate' post '/process_donation/(:customer_id)' => 'store#process_donation', :as => 'process_donation' # config options diff --git a/db/migrate/20240225093946_add_recurring_donation_options_to_options_table.rb b/db/migrate/20240225093946_add_recurring_donation_options_to_options_table.rb deleted file mode 100644 index 8ebc8cbcb..000000000 --- a/db/migrate/20240225093946_add_recurring_donation_options_to_options_table.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRecurringDonationOptionsToOptionsTable < ActiveRecord::Migration - def change - add_column :options, :allow_recurring_donations, :boolean, default: false - add_column :options, :default_donation_type, :string, default: "one" - add_column :options, :recurring_donation_contact_emails, :text - add_column :options, :notify_theatre_about_new_recurring_donation, :boolean, default: true - add_column :options, :notify_threate_about_failed_recurring_donation_charge, :boolean, default: true - end -end diff --git a/db/migrate/20240229121243_create_recurring_donations.rb b/db/migrate/20240229121243_create_recurring_donations.rb deleted file mode 100644 index 3df032d31..000000000 --- a/db/migrate/20240229121243_create_recurring_donations.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateRecurringDonations < ActiveRecord::Migration - def change - create_table :recurring_donations do |t| - t.belongs_to :account_code - t.belongs_to :customer - t.float "amount", default: 0.0 - t.string "comments", limit: 255 - t.timestamps null: false - end - - add_reference :items, :recurring_donation - end -end diff --git a/db/schema.rb b/db/schema.rb index d99fc3304..e979c990d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20240229121243) do +ActiveRecord::Schema.define(version: 20231229020410) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -78,26 +78,25 @@ add_index "customers_labels", ["customer_id", "label_id"], name: "index_customers_labels_on_customer_id_and_label_id", unique: true, using: :btree create_table "items", force: :cascade do |t| - t.integer "vouchertype_id", default: 0, null: false - t.integer "customer_id", default: 0, null: false + t.integer "vouchertype_id", default: 0, null: false + t.integer "customer_id", default: 0, null: false t.integer "showdate_id" - t.string "comments", limit: 255 - t.boolean "fulfillment_needed", default: false, null: false - t.string "promo_code", limit: 255 - t.integer "processed_by_id", default: 2146722771, null: false - t.integer "bundle_id", default: 0, null: false - t.boolean "checked_in", default: false, null: false - t.boolean "walkup", default: false, null: false - t.float "amount", default: 0.0 + t.string "comments", limit: 255 + t.boolean "fulfillment_needed", default: false, null: false + t.string "promo_code", limit: 255 + t.integer "processed_by_id", default: 2146722771, null: false + t.integer "bundle_id", default: 0, null: false + t.boolean "checked_in", default: false, null: false + t.boolean "walkup", default: false, null: false + t.float "amount", default: 0.0 t.integer "account_code_id" t.datetime "updated_at" t.datetime "letter_sent" - t.string "type", limit: 255 + t.string "type", limit: 255 t.integer "order_id" t.boolean "finalized" t.string "seat" t.datetime "sold_on" - t.integer "recurring_donation_id" end add_index "items", ["account_code_id"], name: "index_items_on_account_code_id", using: :btree @@ -199,11 +198,6 @@ t.text "general_reminder_email_notes" t.integer "import_timeout", default: 15, null: false t.string "transactional_bcc_email" - t.boolean "allow_recurring_donations", default: false - t.string "default_donation_type", default: "one" - t.text "recurring_donation_contact_emails" - t.boolean "notify_theatre_about_new_recurring_donation", default: true - t.boolean "notify_threate_about_failed_recurring_donation_charge", default: true end create_table "orders", force: :cascade do |t| @@ -232,15 +226,6 @@ add_index "orders", ["purchaser_id"], name: "index_orders_on_purchaser_id", using: :btree add_index "orders", ["ticket_sales_import_id"], name: "index_orders_on_ticket_sales_import_id", using: :btree - create_table "recurring_donations", force: :cascade do |t| - t.integer "account_code_id" - t.integer "customer_id" - t.float "amount", default: 0.0 - t.string "comments", limit: 255 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - create_table "seating_zones", force: :cascade do |t| t.string "name" t.string "short_name" diff --git a/spec/controllers/recurring_donations_controller_spec.rb b/spec/controllers/recurring_donations_controller_spec.rb deleted file mode 100644 index e7546934b..000000000 --- a/spec/controllers/recurring_donations_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe RecurringDonationsController, type: :controller do - -end diff --git a/spec/controllers/store_controller_spec.rb b/spec/controllers/store_controller_spec.rb index bb03704f4..4243ee8ff 100644 --- a/spec/controllers/store_controller_spec.rb +++ b/spec/controllers/store_controller_spec.rb @@ -101,66 +101,6 @@ end end - describe '#donate: handle account_code_string in URL query parameter' do - context 'when account_code_string is nil (does not exist in URL)' do - it 'redirects to /donate/?account_code_string=' do - - end - end - context 'when account_code_string is invalid (exists in URL but does not correspond to existing AccountCode)' do - it 'redirects to /donate/?account_code_string= and displays error message' do - - end - end - context 'when account_code_string is valid (exists in URL and corresponds to existing AccountCode)' do - it 'creates Donation record with correct account_code_id if transaction completes successfully' do - - end - it 'redirects to /donate with the same valid account_code_string if transactions fails' do - - end - end - end - - describe '#process_donation: start a recurring donation' do - before :each do - @customer = create(:customer) - end - let (:monthly_donation_attempt) { - post :process_donation, - {:customer_id => @customer.id, :donation => 5, :donation_frequency => 'monthly', :credit_card_token => 'dummy', :comments => 'hello I am making a donation'} - } - context 'when donation completes successfully' do - before :each do - allow(Stripe::Charge).to receive(:create).and_return(double("Stripe::Charge", id: 1)) - end - it 'creates a new RecurringDonation record' do - expect{monthly_donation_attempt}.to change {RecurringDonation.count}.by(1) - end - it 'sets new RecurringDonation record attributes to correct values' do - monthly_donation_attempt - recurring_donation_record = RecurringDonation.find(1) - donation_record = Donation.find(1) - expect(recurring_donation_record.account_code_id).to(equal(donation_record.account_code_id)) - expect(recurring_donation_record.customer_id).to(equal(donation_record.customer_id)) - expect(recurring_donation_record.amount).to(equal(donation_record.amount)) - expect(recurring_donation_record.comments).to(equal(donation_record.comments)) - end - it 'adds a foreign key to the corresponding first donation instance' do - monthly_donation_attempt - expect(Donation.find(1).recurring_donation_id).to equal(RecurringDonation.find(1).id) - end - end - context 'when donation completes unsuccessfully' do - before :each do - allow(Stripe::Charge).to receive(:create).and_raise(Stripe::StripeError) - end - it 'does not create new RecurringDonation record if order fails to finalize' do - expect{monthly_donation_attempt}.to change {RecurringDonation.count}.by(0) - end - end - end - describe 'quick donation with nonexistent customer' do before :each do @new_valid_customer = attributes_for(:customer).except(:password,:password_confirmation) diff --git a/spec/factories/recurring_donations.rb b/spec/factories/recurring_donations.rb deleted file mode 100644 index b8ffa8518..000000000 --- a/spec/factories/recurring_donations.rb +++ /dev/null @@ -1,5 +0,0 @@ -FactoryBot.define do - factory :recurring_donation do - - end -end diff --git a/spec/helpers/recurring_donations_helper_spec.rb b/spec/helpers/recurring_donations_helper_spec.rb deleted file mode 100644 index c54722c31..000000000 --- a/spec/helpers/recurring_donations_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the RecurringDonationsHelper. For example: -# -# describe RecurringDonationsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe RecurringDonationsHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/recurring_donation_spec.rb b/spec/models/recurring_donation_spec.rb deleted file mode 100644 index e1165cac5..000000000 --- a/spec/models/recurring_donation_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe RecurringDonation, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end