Merge pull request #150 from houdiniproject/fix_issues_with_deleted_p2p_campaigns
Fix issues with deleted p2p campaigns
This commit is contained in:
commit
6e77a98bff
4 changed files with 24 additions and 5 deletions
|
@ -149,11 +149,17 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<% if @child_campaign.deleted %>
|
||||||
|
<p>
|
||||||
|
Seems like you already have a campaign for that cause! <%= link_to "Click here to reactivate your campaign", "javascript:appl.undelete_p2p(\"/nonprofits/#{@child_campaign.nonprofit_id}/campaigns/#{@child_campaign.id}\")" %>
|
||||||
|
</p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>
|
<p>
|
||||||
Seems like you already have a campaign for that cause! <%= link_to "Click here to see it", @child_campaign.url %>.
|
Seems like you already have a campaign for that cause! <%= link_to "Click here to see it", @child_campaign.url %>.
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -5,6 +5,19 @@ require('../../common/image_uploader')
|
||||||
|
|
||||||
var request = require("../../common/client")
|
var request = require("../../common/client")
|
||||||
|
|
||||||
|
appl.def('undelete_p2p', function (url){
|
||||||
|
appl.def('loading', true)
|
||||||
|
request.put(url + '/soft_delete', {delete: false}).end(function(err, resp) {
|
||||||
|
if (err) {
|
||||||
|
appl.def('loading', false)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
window.location = url
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// setting up some default values
|
// setting up some default values
|
||||||
appl.def('is_signing_up', true)
|
appl.def('is_signing_up', true)
|
||||||
.def('selected_result_index', -1)
|
.def('selected_result_index', -1)
|
||||||
|
|
|
@ -21,7 +21,7 @@ class SlugP2pCampaignNamingAlgorithm < CopyNamingAlgorithm
|
||||||
|
|
||||||
def get_already_used_name_entities(base_name)
|
def get_already_used_name_entities(base_name)
|
||||||
end_name = "\\_\\d{3}"
|
end_name = "\\_\\d{3}"
|
||||||
Campaign.where('slug SIMILAR TO ? AND nonprofit_id = ? AND (deleted IS NULL OR deleted = false)', base_name + end_name, nonprofit_id).select('slug')
|
Campaign.where('slug SIMILAR TO ? AND nonprofit_id = ?', base_name + end_name, nonprofit_id).select('slug')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -24,7 +24,7 @@ describe SlugP2pCampaignNamingAlgorithm do
|
||||||
|
|
||||||
|
|
||||||
describe 'campaigns' do
|
describe 'campaigns' do
|
||||||
let(:campaign) {force_create(:campaign, :slug => @name, nonprofit: nonprofit)}
|
let(:campaign) {force_create(:campaign, :slug => @name, nonprofit: nonprofit, deleted:true)}
|
||||||
let(:campaign2) {force_create(:campaign, :slug => @name2, nonprofit:nonprofit)}
|
let(:campaign2) {force_create(:campaign, :slug => @name2, nonprofit:nonprofit)}
|
||||||
let(:campaigns_at_max_copies) { (0..999).collect{|i|
|
let(:campaigns_at_max_copies) { (0..999).collect{|i|
|
||||||
force_create(:campaign, slug: "#{@copy_base}_#{"%03d" % i}", nonprofit:nonprofit)
|
force_create(:campaign, slug: "#{@copy_base}_#{"%03d" % i}", nonprofit:nonprofit)
|
||||||
|
|
Loading…
Reference in a new issue