From 597472b5c681b72efad4d155b61cfcdb02de2265 Mon Sep 17 00:00:00 2001 From: Danny Skubak Date: Tue, 3 Dec 2019 19:02:56 -0500 Subject: [PATCH] remove funded proposals from arbiter count (#92) --- admin/src/components/Home/index.tsx | 2 +- admin/src/util/filters.ts | 41 ++++++++++++++++++++--------- backend/grant/admin/views.py | 1 + backend/grant/utils/pagination.py | 5 ++++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/admin/src/components/Home/index.tsx b/admin/src/components/Home/index.tsx index 66ebb62a..beb850bc 100644 --- a/admin/src/components/Home/index.tsx +++ b/admin/src/components/Home/index.tsx @@ -32,7 +32,7 @@ class Home extends React.Component {
There are {proposalNoArbiterCount}{' '} live proposals without an arbiter.{' '} - + Click here {' '} to view them. diff --git a/admin/src/util/filters.ts b/admin/src/util/filters.ts index f861d1fa..8815e1cf 100644 --- a/admin/src/util/filters.ts +++ b/admin/src/util/filters.ts @@ -59,7 +59,21 @@ const PROPOSAL_FILTERS = PROPOSAL_STATUSES.map(s => ({ color: s.tagColor, group: 'Milestone', })), - ); + ) + .concat([ + { + id: 'ACCEPTED_WITH_FUNDING', + display: 'Accepted With Funding', + color: '#2D2A26', + group: 'Funding', + }, + { + id: 'ACCEPTED_WITHOUT_FUNDING', + display: 'Accepted Without Funding', + color: '#108ee9', + group: 'Funding', + }, + ]); export const proposalFilters: Filters = { list: PROPOSAL_FILTERS, @@ -87,17 +101,20 @@ const CONTRIBUTION_FILTERS = CONTRIBUTION_STATUSES.map(s => ({ display: `Status: ${s.tagDisplay}`, color: s.tagColor, group: 'Status', -})).concat([{ - id: 'REFUNDABLE', - display: 'Refundable', - color: '#afd500', - group: 'Refundable', -}, { - id: 'DONATION', - display: 'Donations', - color: '#afd500', - group: 'Donations', -}]); +})).concat([ + { + id: 'REFUNDABLE', + display: 'Refundable', + color: '#afd500', + group: 'Refundable', + }, + { + id: 'DONATION', + display: 'Donations', + color: '#afd500', + group: 'Donations', + }, +]); export const contributionFilters: Filters = { list: CONTRIBUTION_FILTERS, diff --git a/backend/grant/admin/views.py b/backend/grant/admin/views.py index b71e4c3b..6b444dae 100644 --- a/backend/grant/admin/views.py +++ b/backend/grant/admin/views.py @@ -145,6 +145,7 @@ def stats(): .filter(Proposal.status == ProposalStatus.LIVE) \ .filter(ProposalArbiter.status == ProposalArbiterStatus.MISSING) \ .filter(Proposal.stage != ProposalStage.CANCELED) \ + .filter(Proposal.accepted_with_funding == True) \ .scalar() proposal_milestone_payouts_count = db.session.query(func.count(Proposal.id)) \ .join(Proposal.milestones) \ diff --git a/backend/grant/utils/pagination.py b/backend/grant/utils/pagination.py index 3d02e0eb..1860f7da 100644 --- a/backend/grant/utils/pagination.py +++ b/backend/grant/utils/pagination.py @@ -58,6 +58,7 @@ class ProposalPagination(Pagination): self.FILTERS.extend([f'CAT_{c}' for c in Category.list()]) self.FILTERS.extend([f'ARBITER_{c}' for c in ProposalArbiterStatus.list()]) self.FILTERS.extend([f'MILESTONE_{c}' for c in MilestoneStage.list()]) + self.FILTERS.extend(['ACCEPTED_WITH_FUNDING', 'ACCEPTED_WITHOUT_FUNDING']) self.PAGE_SIZE = 9 self.SORT_MAP = { 'CREATED:DESC': Proposal.date_created.desc(), @@ -102,6 +103,10 @@ class ProposalPagination(Pagination): if milestone_filters: query = query.join(Proposal.milestones) \ .filter(Milestone.stage.in_(milestone_filters)) + if 'ACCEPTED_WITH_FUNDING' in filters: + query = query.filter(Proposal.accepted_with_funding == True) + if 'ACCEPTED_WITHOUT_FUNDING' in filters: + query = query.filter(Proposal.accepted_with_funding == False) # SORT (see self.SORT_MAP) if sort: