-
-
Save dnch/82170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def donate | |
@heroPage = HeroPage.search_url(params[:url], DateTime.now) | |
unless @heroPage | |
redirect_to :action=>"the_unknown_hero" | |
return | |
else | |
@donation = Donation.new() | |
# if @donation.save? then session[:mydonation_id] = @donation.id end | |
@currency = CurrencyUtils.determine_local_currency_from_hero_page(@heroPage) | |
hero_page_variables("preview", true) | |
@team_member_dedication = TeamUtils.team_member_donation_dedication(@heroPage) | |
@capture_fields = DataCapture.retrieve_capture_fields(@heroPage, "donation") | |
hero_page_event_layout("hero_page_donation", {:alternative_layout=>"hero_page_donation", :hero_page=>@heroPage}) | |
end | |
end | |
# UK only method for determining eligibility for gift aid tax rebate. | |
def donation_uk_giftaid | |
unless request.post? | |
redirect_to :action=>"donate" | |
return | |
end | |
@heroPage = HeroPage.search_url(params[:url], DateTime.now) | |
hero_page_variables("preview", true) | |
if session[:mydonation_id] | |
@donation = Donation.find_by_id(session[:mydonation_id]) | |
else | |
@donation = Donation.new() | |
end | |
## | |
# okay, change of tact. update your @donation with the attributes here... | |
# they'll be captured in the database during the next save later down this file | |
@donation.attributes = params[:donation] | |
if (! @heroPage) and (params[:donation] == nil) | |
redirect_to :action=>"the_unknown_hero" | |
else | |
if params[:donation][:amount].empty? | |
amount = params['donation_amount'][:amount] if params['donation_amount'] | |
else | |
amount = params[:donation][:amount] | |
end | |
end | |
@donation.amount = amount | |
@currency = CurrencyUtils.determine_local_currency_from_hero_page(@heroPage) | |
@donation.currency = @currency | |
puts "\n\n\n\n\n\n\n\n\n\n\n" | |
puts @donation.inspect | |
if @donation.save then session[:mydonation_id] = @donation.id end | |
# get the donation currency from the hero_page | |
@answers = UkGiftAid.find(:first, :conditions => { 'giftaidable_id' => '1', 'giftaidable_type' => 'donation'}) | |
hero_page_event_layout("hero_page_donation", {:alternative_layout => "hero_page_donation", :hero_page=>@heroPage}) | |
end | |
def donation_create | |
unless request.post? | |
redirect_to :action=>"donate" | |
return | |
end | |
@heroPage = HeroPage.search_url(params[:url], DateTime.now) | |
@team_member_dedication = TeamUtils.team_member_donation_dedication(@heroPage) | |
hero_page_variables("preview", true) | |
if (! @heroPage) and (params[:donation] == nil) | |
redirect_to :action=>"the_unknown_hero" | |
else | |
if params[:donation][:amount].empty? | |
amount = params['donation_amount'][:amount] if params['donation_amount'] | |
else | |
amount = params[:donation][:amount] | |
end | |
@currency = CurrencyUtils.determine_local_currency_from_hero_page(@heroPage) | |
# get the donation currency from the hero_page | |
if @activeHero | |
@donation = Donation.new("amount"=>amount, | |
:add_to_edh_mailing_list => params[:donation][:add_to_edh_mailing_list], | |
:show_email_to_hero => params[:donation][:show_email_to_hero], | |
:add_to_charity_mailing_list => params[:donation][:add_to_charity_mailing_list], | |
:comments => params[:donation][:comments], | |
:firstname => params[:donation][:firstname], | |
:hero=>@activeHero, | |
:heroPage=>@heroPage, | |
:charityProfile=>@heroPage.charityProfile, | |
:donation_status_id =>1, | |
:donation_type_id=>3, | |
:currency=>@currency) | |
# if the hero is signed in do this donation | |
else | |
# else do this donation | |
@donation = Donation.new("amount"=>amount, | |
:add_to_edh_mailing_list => params[:donation][:add_to_edh_mailing_list], | |
:show_email_to_hero => params[:donation][:show_email_to_hero], | |
:add_to_charity_mailing_list => params[:donation][:add_to_charity_mailing_list], | |
:comments => params[:donation][:comments], | |
:firstname => params[:donation][:firstname], | |
:heroPage=>@heroPage, | |
:charityProfile=>@heroPage.charityProfile, | |
:donation_status_id =>1, | |
:donation_type_id=>1, | |
:currency=>@currency) | |
end | |
# Determine payment gateway for donation, use the nil feature in | |
pm = PaymentGatewayManager.make_from_model(@heroPage.event,true,true) | |
@donation.payment_manager_id = pm.payment_manager_id if pm | |
begin | |
DataCapture.validate_fields_and_raise_exception(@heroPage,params[:captured_data], "donation") | |
rescue | |
process_donation_errors | |
else | |
if @donation.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment