Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

delete donation fix

  • Loading branch information...
commit d38188baaf09083abd07e2b60fbc96f32775601b 1 parent 15db7e1
Kyle Shank authored
6 app/controllers/donations_controller.rb
@@ -67,6 +67,12 @@ def destroy
67 67 redirect_to campaign_permalink_path(@campaign)
68 68 end
69 69
  70 + def delete
  71 + @donation = current_twitter_account.donations.find(params[:id]) if current_twitter_account
  72 + @donation = current_facebook_account.donations.find(params[:id]) if !@donation && current_facebook_account
  73 + render_not_found and return unless @donation
  74 + end
  75 +
70 76 private
71 77
72 78 def load_campaign
4 app/views/campaigns/show.html.erb
@@ -32,7 +32,7 @@
32 32 <% if logged_in? and @campaign.twitter_account and current_twitter_account and (@campaign.twitter_account.id == current_twitter_account.id) %>
33 33 <li><%= link_to "Publish", new_campaign_twitter_status_path(@campaign), :id => "publish_twitter", :class => "button twitter" %></li>
34 34 <% elsif @twitter_donation %>
35   - <li><%= link_to "Un-Donate", campaign_donation_path(@campaign,@twitter_donation), :id => "undonate_twitter", :class => "button twitter", :confirm => "Are you sure?", :method => :delete %></li>
  35 + <li><%= link_to "Un-Donate", delete_campaign_donation_path(@campaign,@twitter_donation), :id => "undonate_twitter", :class => "button twitter" %></li>
36 36 <% elsif logged_in? and @campaign.twitter_account and @campaign.facebook_account and !current_twitter_account and current_facebook_account and (@campaign.facebook_account.id == current_facebook_account.id) %>
37 37 <li><%= link_to "Sign In", new_twitter_account_path, :id => "signin_twitter", :class => "button twitter" %></li>
38 38 <% elsif @campaign.twitter_account %>
@@ -42,7 +42,7 @@
42 42 <li><%= link_to "Publish", new_campaign_facebook_status_path(@campaign), :id => "publish_facebook", :class => "button facebook" %></li>
43 43 <% end%>
44 44 <% if @facebook_donation %>
45   - <li><%= link_to "Un-Donate", campaign_donation_path(@campaign,@facebook_donation), :id => "undonate_facebook", :class => "button facebook", :confirm => "Are you sure?", :method => :delete %></li>
  45 + <li><%= link_to "Un-Donate", delete_campaign_donation_path(@campaign,@facebook_donation), :id => "undonate_facebook", :class => "button facebook" %></li>
46 46 <% elsif logged_in? and @campaign.twitter_account and @campaign.facebook_account and !current_facebook_account and @campaign.twitter_account and current_twitter_account and (@campaign.twitter_account.id == current_twitter_account.id) %>
47 47 <li><%= link_to "Sign In", new_facebook_account_path, :id => "signin_facebook", :class => "button facebook" %></li>
48 48 <% elsif @campaign.facebook_page_uid %>
5 app/views/donations/delete.html.erb
... ... @@ -0,0 +1,5 @@
  1 +<h1><%=@donation.campaign.name%></h1>
  2 +<p>Are you sure you want to delete this <%= @donation.account.type=="TwitterAccount" ? "Twitter" : "Facebook" %> donation to <%=link_to @donation.campaign.name, campaign_path(@donation.campaign)%>?</p>
  3 +<p>
  4 + <%=button_to "Delete Donation", campaign_donation_path(@campaign,@donation), :method => :delete%>
  5 +</p>
3  config/routes.rb
@@ -35,6 +35,9 @@
35 35 get :facebook
36 36 match 'facebook' => "donations#facebook_create", :as => :facebook_create, :via => :post
37 37 end
  38 + member do
  39 + get :delete
  40 + end
38 41 end
39 42 resources :twitter_statuses
40 43 resources :facebook_statuses

0 comments on commit d38188b

Please sign in to comment.
Something went wrong with that request. Please try again.