From 62ffd302081c575a7a39e5ab5c08f4a8b42b0962 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 27 May 2019 14:16:48 -0500 Subject: [PATCH 1/7] admin: add proposal STAGE_NOT_CANCELED filter --- admin/src/types.ts | 1 + admin/src/util/statuses.ts | 8 ++++++++ backend/grant/utils/pagination.py | 9 +++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/admin/src/types.ts b/admin/src/types.ts index f7eee8af..72f75e63 100644 --- a/admin/src/types.ts +++ b/admin/src/types.ts @@ -87,6 +87,7 @@ export enum PROPOSAL_STAGE { COMPLETED = 'COMPLETED', FAILED = 'FAILED', CANCELED = 'CANCELED', + NOT_CANCELED = 'NOT_CANCELED', } export interface Proposal { proposalId: number; diff --git a/admin/src/util/statuses.ts b/admin/src/util/statuses.ts index 71cce6d7..967fffa8 100644 --- a/admin/src/util/statuses.ts +++ b/admin/src/util/statuses.ts @@ -12,6 +12,7 @@ export interface StatusSoT { tagDisplay: string; tagColor: string; hint: string; + not?: boolean; } export const MILESTONE_STAGES: Array> = [ @@ -131,6 +132,13 @@ export const PROPOSAL_STAGES: Array> = [ hint: 'Proposal was canceled by an admin and is currently refunding all contributors.', }, + { + id: PROPOSAL_STAGE.NOT_CANCELED, + tagDisplay: 'NOT Canceled', + tagColor: '#eb4118', + hint: 'Proposal has NOT been canceled.', + not: true, + }, ]; export const PROPOSAL_ARBITER_STATUSES: Array> = [ diff --git a/backend/grant/utils/pagination.py b/backend/grant/utils/pagination.py index 5ce0935f..65022eda 100644 --- a/backend/grant/utils/pagination.py +++ b/backend/grant/utils/pagination.py @@ -10,7 +10,9 @@ from .enums import ProposalStatus, ProposalStage, Category, ContributionStatus, def extract_filters(sw, strings): - return [f[len(sw):] for f in strings if f.startswith(sw)] + filters = [f[len(sw):] for f in strings if f.startswith(sw)] + filters = [f for f in filters if not f.startswith('NOT_')] + return filters class PaginationException(Exception): @@ -52,6 +54,7 @@ class ProposalPagination(Pagination): def __init__(self): self.FILTERS = [f'STATUS_{s}' for s in ProposalStatus.list()] self.FILTERS.extend([f'STAGE_{s}' for s in ProposalStage.list()]) + self.FILTERS.extend([f'STAGE_NOT_{s}' for s in ProposalStage.list()]) 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()]) @@ -80,6 +83,7 @@ class ProposalPagination(Pagination): self.validate_filters(filters) status_filters = extract_filters('STATUS_', filters) stage_filters = extract_filters('STAGE_', filters) + stage_not_filters = extract_filters('STAGE_NOT_', filters, ) cat_filters = extract_filters('CAT_', filters) arbiter_filters = extract_filters('ARBITER_', filters) milestone_filters = extract_filters('MILESTONE_', filters) @@ -88,6 +92,8 @@ class ProposalPagination(Pagination): query = query.filter(Proposal.status.in_(status_filters)) if stage_filters: query = query.filter(Proposal.stage.in_(stage_filters)) + if stage_not_filters: + query = query.filter(Proposal.stage.notin_(stage_not_filters)) if cat_filters: query = query.filter(Proposal.category.in_(cat_filters)) if arbiter_filters: @@ -177,7 +183,6 @@ class ContributionPagination(Pagination): Proposal.stage == ProposalStage.CANCELED, )) - # SORT (see self.SORT_MAP) if sort: self.validate_sort(sort) From 1ae16004e52dbfba4185a204b6f70fbbe3abd8f6 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 27 May 2019 14:43:50 -0500 Subject: [PATCH 2/7] be: filter canceled from stats ms payouts count --- backend/grant/admin/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/grant/admin/views.py b/backend/grant/admin/views.py index a9aba16b..44ba82b8 100644 --- a/backend/grant/admin/views.py +++ b/backend/grant/admin/views.py @@ -149,6 +149,7 @@ def stats(): proposal_milestone_payouts_count = db.session.query(func.count(Proposal.id)) \ .join(Proposal.milestones) \ .filter(Proposal.status == ProposalStatus.LIVE) \ + .filter(Proposal.stage != ProposalStage.CANCELED) \ .filter(Milestone.stage == MilestoneStage.ACCEPTED) \ .scalar() # Count contributions on proposals that didn't get funded for users who have specified a refund address From 0c2303aaa6c1ddfa65dfad8bb1ab86f782209717 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 27 May 2019 14:45:38 -0500 Subject: [PATCH 3/7] admin: add STAGE_NOT_CANCELED filters to links from Home --- admin/src/components/Home/index.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/admin/src/components/Home/index.tsx b/admin/src/components/Home/index.tsx index e0845089..66ebb62a 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. @@ -42,14 +42,16 @@ class Home extends React.Component {
There are{' '} {proposalMilestonePayoutsCount} proposals with approved payouts.{' '} - Click here to view - them. + + Click here + {' '} + to view them.
), !!contributionRefundableCount && (
- There are {contributionRefundableCount}{' '} - contributions ready to be refunded.{' '} + There are{' '} + {contributionRefundableCount} contributions ready to be refunded.{' '} Click here to view them.
), From 17da8c15d8a156beddd539c30d3fc7aa5366560c Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 27 May 2019 14:52:19 -0500 Subject: [PATCH 4/7] admin: remove delete btn from ProposalDetail --- admin/src/components/ProposalDetail/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/components/ProposalDetail/index.tsx b/admin/src/components/ProposalDetail/index.tsx index 2067569f..133bc212 100644 --- a/admin/src/components/ProposalDetail/index.tsx +++ b/admin/src/components/ProposalDetail/index.tsx @@ -411,7 +411,7 @@ class ProposalDetailNaked extends React.Component { {/* ACTIONS */} - {renderDeleteControl()} + {/* {renderDeleteControl()} */} {renderCancelControl()} {renderArbiterControl()} {renderBountyControl()} From 0c94c11bd5b4140f8c03535f8d8e24496bcf0a43 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 27 May 2019 15:17:55 -0500 Subject: [PATCH 5/7] admin: separate sourcemaps for production build --- admin/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/webpack.config.js b/admin/webpack.config.js index 4e0cfc30..12dbca31 100644 --- a/admin/webpack.config.js +++ b/admin/webpack.config.js @@ -18,7 +18,7 @@ module.exports = { publicPath: '/', chunkFilename: isDev ? '[name].chunk.js' : '[name].[chunkhash:8].chunk.js', }, - devtool: 'inline-source-map', + devtool: isDev ? 'inline-source-map' : 'source-map', devServer: { port: 3500, contentBase: './build', From 0cc79ad645508a456b7c2b48c0d640fc78e081d4 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 27 May 2019 15:19:08 -0500 Subject: [PATCH 6/7] admin: comment ProposalDetail delete fns to apease tsc --- admin/src/components/ProposalDetail/index.tsx | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/admin/src/components/ProposalDetail/index.tsx b/admin/src/components/ProposalDetail/index.tsx index 133bc212..fca07a1d 100644 --- a/admin/src/components/ProposalDetail/index.tsx +++ b/admin/src/components/ProposalDetail/index.tsx @@ -64,18 +64,18 @@ class ProposalDetailNaked extends React.Component { return m.datePaid ? prev - parseFloat(m.payoutPercent) : prev; }, 100); - const renderDeleteControl = () => ( - - - - ); + // const renderDeleteControl = () => ( + // + // + // + // ); const renderCancelControl = () => { const disabled = this.getCancelAndRefundDisabled(); @@ -507,10 +507,10 @@ class ProposalDetailNaked extends React.Component { store.fetchProposalDetail(this.getIdFromQuery()); }; - private handleDelete = () => { - if (!store.proposalDetail) return; - store.deleteProposal(store.proposalDetail.proposalId); - }; + // private handleDelete = () => { + // if (!store.proposalDetail) return; + // store.deleteProposal(store.proposalDetail.proposalId); + // }; private handleCancelCancel = () => { this.setState({ showCancelAndRefundPopover: false }); From c0904d9c00db352419600b232b524b2210a5d995 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 27 May 2019 20:07:29 -0500 Subject: [PATCH 7/7] admin: remove commented code --- admin/src/components/ProposalDetail/index.tsx | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/admin/src/components/ProposalDetail/index.tsx b/admin/src/components/ProposalDetail/index.tsx index fca07a1d..a7d587a2 100644 --- a/admin/src/components/ProposalDetail/index.tsx +++ b/admin/src/components/ProposalDetail/index.tsx @@ -64,19 +64,6 @@ class ProposalDetailNaked extends React.Component { return m.datePaid ? prev - parseFloat(m.payoutPercent) : prev; }, 100); - // const renderDeleteControl = () => ( - // - // - // - // ); - const renderCancelControl = () => { const disabled = this.getCancelAndRefundDisabled(); @@ -411,7 +398,6 @@ class ProposalDetailNaked extends React.Component { {/* ACTIONS */} - {/* {renderDeleteControl()} */} {renderCancelControl()} {renderArbiterControl()} {renderBountyControl()} @@ -507,11 +493,6 @@ class ProposalDetailNaked extends React.Component { store.fetchProposalDetail(this.getIdFromQuery()); }; - // private handleDelete = () => { - // if (!store.proposalDetail) return; - // store.deleteProposal(store.proposalDetail.proposalId); - // }; - private handleCancelCancel = () => { this.setState({ showCancelAndRefundPopover: false }); };