Browse files

delete donation fix

  • Loading branch information...
1 parent 15db7e1 commit d38188baaf09083abd07e2b60fbc96f32775601b @kyleshank committed Dec 4, 2011
View
6 app/controllers/donations_controller.rb
@@ -67,6 +67,12 @@ def destroy
redirect_to campaign_permalink_path(@campaign)
end
+ def delete
+ @donation = current_twitter_account.donations.find(params[:id]) if current_twitter_account
+ @donation = current_facebook_account.donations.find(params[:id]) if !@donation && current_facebook_account
+ render_not_found and return unless @donation
+ end
+
private
def load_campaign
View
4 app/views/campaigns/show.html.erb
@@ -32,7 +32,7 @@
<% if logged_in? and @campaign.twitter_account and current_twitter_account and (@campaign.twitter_account.id == current_twitter_account.id) %>
<li><%= link_to "Publish", new_campaign_twitter_status_path(@campaign), :id => "publish_twitter", :class => "button twitter" %></li>
<% elsif @twitter_donation %>
- <li><%= link_to "Un-Donate", campaign_donation_path(@campaign,@twitter_donation), :id => "undonate_twitter", :class => "button twitter", :confirm => "Are you sure?", :method => :delete %></li>
+ <li><%= link_to "Un-Donate", delete_campaign_donation_path(@campaign,@twitter_donation), :id => "undonate_twitter", :class => "button twitter" %></li>
<% 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) %>
<li><%= link_to "Sign In", new_twitter_account_path, :id => "signin_twitter", :class => "button twitter" %></li>
<% elsif @campaign.twitter_account %>
@@ -42,7 +42,7 @@
<li><%= link_to "Publish", new_campaign_facebook_status_path(@campaign), :id => "publish_facebook", :class => "button facebook" %></li>
<% end%>
<% if @facebook_donation %>
- <li><%= link_to "Un-Donate", campaign_donation_path(@campaign,@facebook_donation), :id => "undonate_facebook", :class => "button facebook", :confirm => "Are you sure?", :method => :delete %></li>
+ <li><%= link_to "Un-Donate", delete_campaign_donation_path(@campaign,@facebook_donation), :id => "undonate_facebook", :class => "button facebook" %></li>
<% 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) %>
<li><%= link_to "Sign In", new_facebook_account_path, :id => "signin_facebook", :class => "button facebook" %></li>
<% elsif @campaign.facebook_page_uid %>
View
5 app/views/donations/delete.html.erb
@@ -0,0 +1,5 @@
+<h1><%=@donation.campaign.name%></h1>
+<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>
+<p>
+ <%=button_to "Delete Donation", campaign_donation_path(@campaign,@donation), :method => :delete%>
+</p>
View
3 config/routes.rb
@@ -35,6 +35,9 @@
get :facebook
match 'facebook' => "donations#facebook_create", :as => :facebook_create, :via => :post
end
+ member do
+ get :delete
+ end
end
resources :twitter_statuses
resources :facebook_statuses

0 comments on commit d38188b

Please sign in to comment.