Fix peer-to-peer action

This commit is contained in:
Kasia Jarmołkowicz 2018-07-05 16:11:08 +02:00 committed by Eric Schultz
parent ec3ca228a8
commit 77a59b0037
2 changed files with 13 additions and 7 deletions

View file

@ -110,16 +110,22 @@ class CampaignsController < ApplicationController
session[:donor_signup_url] = request.env["REQUEST_URI"] session[:donor_signup_url] = request.env["REQUEST_URI"]
@nonprofit = Nonprofit.find_by_id(params[:npo_id]) @nonprofit = Nonprofit.find_by_id(params[:npo_id])
@parent_campaign = Campaign.find_by_id(params[:campaign_id]) @parent_campaign = Campaign.find_by_id(params[:campaign_id])
if params[:campaign_id].present? && !@parent_campaign
raise ActionController::RoutingError.new('Not Found')
end
if current_user
@profile = current_user.profile
@child_campaign = Campaign.where( @child_campaign = Campaign.where(
profile_id: current_user.profile.id, profile_id: @profile.id,
parent_campaign_id: @parent_campaign.id parent_campaign_id: @parent_campaign.id
).first if @parent_campaign ).first
@profile = current_user.profile if current_user end
end end
private private
# TODO: test if this can be passed by p2p campaign editor
def check_nonprofit_status def check_nonprofit_status
if !current_role?(:super_admin) && !current_nonprofit.published if !current_role?(:super_admin) && !current_nonprofit.published
raise ActionController::RoutingError.new('Not Found') raise ActionController::RoutingError.new('Not Found')

View file

@ -38,7 +38,7 @@
<%= IncludeAsset.js '/client/js/campaigns/peer_to_peer/page.js' %> <%= IncludeAsset.js '/client/js/campaigns/peer_to_peer/page.js' %>
<% end %> <% end %>
<% if @parent_campaign.banner_image_url %> <% if @parent_campaign && @parent_campaign.banner_image_url %>
<div class='campaign-banner u-margin'> <div class='campaign-banner u-margin'>
<img src='<%= @parent_campaign.banner_image_url %>'> <img src='<%= @parent_campaign.banner_image_url %>'>
</div> </div>