Merge pull request #151 from houdiniproject/more_p2p_updates

Updates to improve child campaign display
This commit is contained in:
Eric Schultz 2019-02-06 13:34:58 -06:00 committed by GitHub
commit a7b56c80ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -9,14 +9,19 @@ class CampaignsController < ApplicationController
def index
@nonprofit = current_nonprofit
@campaigns = @nonprofit.campaigns.includes(:nonprofit).not_deleted.order('created_at desc')
if (current_nonprofit_user?)
@campaigns = @nonprofit.campaigns.includes(:nonprofit).not_deleted.order('created_at desc')
@deleted_campaigns = @nonprofit.campaigns.includes(:nonprofit).deleted.order('created_at desc')
else
@campaigns = @nonprofit.campaigns.includes(:nonprofit).not_deleted.not_a_child.order('created_at desc')
@deleted_campaigns = @nonprofit.campaigns.includes(:nonprofit).deleted.not_a_child.order('created_at desc')
end
respond_to do |format|
format.html do
@active_campaigns = @campaigns.active
@past_campaigns = @campaigns.past
@unpublished_campaigns = @campaigns.unpublished
@deleted_campaigns = @nonprofit.campaigns.deleted.order('created_at desc')
end
format.json do

View file

@ -19,7 +19,7 @@
@profiles = @nonprofit.profiles.order('total_raised DESC').limit(5).includes(:user).uniq
events = @nonprofit.events.not_deleted.order('start_datetime desc')
campaigns = @nonprofit.campaigns.not_deleted.order('created_at desc')
campaigns = @nonprofit.campaigns.not_deleted.not_a_child.order('created_at desc')
@events = events.upcoming
@any_past_events = events.past.any?

View file

@ -76,6 +76,7 @@ class Campaign < ActiveRecord::Base
scope :unpublished, -> {where(:published => [nil, false])}
scope :not_deleted, -> {where(deleted: [nil, false])}
scope :deleted, -> {where(deleted: true)}
scope :not_a_child, -> {where(parent_campaign_id: nil)}
before_validation do
if self.goal_amount_dollars.present?