Don't allow to create more than one child campaign per user
This commit is contained in:
parent
aaddc721bf
commit
6b94b10979
2 changed files with 32 additions and 21 deletions
|
@ -111,6 +111,10 @@ 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])
|
||||||
|
@child_campaign = Campaign.where(
|
||||||
|
profile_id: current_user.profile.id,
|
||||||
|
parent_campaign_id: @parent_campaign.id
|
||||||
|
).first if @parent_campaign
|
||||||
@profile = current_user.profile if current_user
|
@profile = current_user.profile if current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -116,29 +116,36 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<p class='strong u-marginBottom--15'>Start your campaign</p>
|
<% if !@child_campaign %>
|
||||||
<span class='annot'>5 minutes</span>
|
<p class='strong u-marginBottom--15'>Start your campaign</p>
|
||||||
<div class='u-paddingLeft--20 u-maxWidth--500'>
|
<span class='annot'>5 minutes</span>
|
||||||
<p>Use our simple wizard to create your campaign for
|
<div class='u-paddingLeft--20 u-maxWidth--500'>
|
||||||
<strong>
|
<p>Use our simple wizard to create your campaign for
|
||||||
<!--= show_if selected_result -->
|
<strong>
|
||||||
<!--= put selected_result.name -->.
|
<!--= show_if selected_result -->
|
||||||
</strong>
|
<!--= put selected_result.name -->.
|
||||||
<strong>
|
</strong>
|
||||||
<!--= hide_if selected_result -->
|
<strong>
|
||||||
your favorite nonprofit.
|
<!--= hide_if selected_result -->
|
||||||
</strong>
|
your favorite nonprofit.
|
||||||
</p>
|
</strong>
|
||||||
<p><small>If you need any further help setting up your campaign, check out <a target='_blank' href='/help/peer-to-peer-campaigns-essentials-package-feature'>this handy article</a>.</small></p>
|
</p>
|
||||||
<div class='u-centered u-padding--15'>
|
<p><small>If you need any further help setting up your campaign, check out <a target='_blank' href='/help/peer-to-peer-campaigns-essentials-package-feature'>this handy article</a>.</small></p>
|
||||||
<button class='button orange'>
|
<div class='u-centered u-padding--15'>
|
||||||
<!--= show_if (all is_logged_in is_confirmed selected_result) -->
|
<button class='button orange'>
|
||||||
<!--= on 'click' (open_modal selected_result.modal_id) -->
|
<!--= show_if (all is_logged_in is_confirmed selected_result) -->
|
||||||
Start Campaign
|
<!--= on 'click' (open_modal selected_result.modal_id) -->
|
||||||
</button>
|
Start Campaign
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% else %>
|
||||||
|
<p>
|
||||||
|
Seems like you already have a campaign for that cause! <%= link_to "Click here to see it", @child_campaign.url %>.
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
Loading…
Reference in a new issue