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,6 +116,7 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
|
<% if !@child_campaign %>
|
||||||
<p class='strong u-marginBottom--15'>Start your campaign</p>
|
<p class='strong u-marginBottom--15'>Start your campaign</p>
|
||||||
<span class='annot'>5 minutes</span>
|
<span class='annot'>5 minutes</span>
|
||||||
<div class='u-paddingLeft--20 u-maxWidth--500'>
|
<div class='u-paddingLeft--20 u-maxWidth--500'>
|
||||||
|
@ -138,7 +139,13 @@
|
||||||
</button>
|
</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