admin: add proposal STAGE_NOT_CANCELED filter

This commit is contained in:
Aaron 2019-05-27 14:16:48 -05:00
parent 0ab9cb6e2b
commit 62ffd30208
No known key found for this signature in database
GPG Key ID: 3B5B7597106F0A0E
3 changed files with 16 additions and 2 deletions

View File

@ -87,6 +87,7 @@ export enum PROPOSAL_STAGE {
COMPLETED = 'COMPLETED',
FAILED = 'FAILED',
CANCELED = 'CANCELED',
NOT_CANCELED = 'NOT_CANCELED',
}
export interface Proposal {
proposalId: number;

View File

@ -12,6 +12,7 @@ export interface StatusSoT<E> {
tagDisplay: string;
tagColor: string;
hint: string;
not?: boolean;
}
export const MILESTONE_STAGES: Array<StatusSoT<MILESTONE_STAGE>> = [
@ -131,6 +132,13 @@ export const PROPOSAL_STAGES: Array<StatusSoT<PROPOSAL_STAGE>> = [
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<StatusSoT<PROPOSAL_ARBITER_STATUS>> = [

View File

@ -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)