Skip to content

Commit

Permalink
delete remnants of recurring donation feature from this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
winsonwan committed Mar 13, 2024
1 parent 7c337d3 commit 15788b6
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 245 deletions.
2 changes: 0 additions & 2 deletions app/assets/javascripts/recurring_donations.js

This file was deleted.

3 changes: 0 additions & 3 deletions app/assets/stylesheets/recurring_donations.scss

This file was deleted.

4 changes: 1 addition & 3 deletions app/controllers/options_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class OptionsController < ApplicationController

before_filter :is_admin_filter

def index
@o = Option.first
end
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/recurring_donations_controller.rb

This file was deleted.

7 changes: 0 additions & 7 deletions app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/recurring_donations_helper.rb

This file was deleted.

8 changes: 3 additions & 5 deletions app/models/items/donation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
16 changes: 0 additions & 16 deletions app/models/recurring_donation.rb

This file was deleted.

32 changes: 0 additions & 32 deletions app/views/options/index.html.haml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions app/views/store/donate.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions config/locales/en.option_descriptions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -75,7 +75,7 @@
resources :shows, :except => [:show] do
resources :showdates, :except => [:index]
end

resources :valid_vouchers, :except => [:index]
resources :vouchertypes do
member do
Expand Down Expand Up @@ -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
Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions db/migrate/20240229121243_create_recurring_donations.rb

This file was deleted.

39 changes: 12 additions & 27 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 0 additions & 5 deletions spec/controllers/recurring_donations_controller_spec.rb

This file was deleted.

60 changes: 0 additions & 60 deletions spec/controllers/store_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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=<default donation account code>' 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=<default donation account code> 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)
Expand Down
5 changes: 0 additions & 5 deletions spec/factories/recurring_donations.rb

This file was deleted.

15 changes: 0 additions & 15 deletions spec/helpers/recurring_donations_helper_spec.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/models/recurring_donation_spec.rb

This file was deleted.

0 comments on commit 15788b6

Please sign in to comment.