Merge pull request #151 from houdiniproject/more_p2p_updates
Updates to improve child campaign display
This commit is contained in:
commit
a7b56c80ae
3 changed files with 9 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in a new issue