Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ScheE endpoint sortable by support_oppose_indicator #3520

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/test_itemized.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,3 +741,23 @@ def test_filters_sched_e_efile(self):
results = self._results(api.url_for(ScheduleEEfileView, **{label: values[0]}))
assert len(results) == 1
assert results[0][column.key] == values[0]

def test_schedule_e_sort_args_descending(self):
[
factories.ScheduleEFactory(expenditure_amount=100, expenditure_date=datetime.date(2016, 1, 1),
committee_id='101', support_oppose_indicator='s'),
factories.ScheduleEFactory(expenditure_amount=100, expenditure_date=datetime.date(2016, 1, 1),
committee_id='101', support_oppose_indicator='o'),
]
results = self._results(api.url_for(ScheduleEView, sort='-support_oppose_indicator'))
self.assertEqual(results[0]['support_oppose_indicator'], 's')

def test_schedule_e_sort_args_ascending(self):
[
factories.ScheduleEFactory(expenditure_amount=100, expenditure_date=datetime.date(2016, 1, 1),
committee_id='101', support_oppose_indicator='s'),
factories.ScheduleEFactory(expenditure_amount=100, expenditure_date=datetime.date(2016, 1, 1),
committee_id='101', support_oppose_indicator='o'),
]
results = self._results(api.url_for(ScheduleEView, sort='support_oppose_indicator'))
self.assertEqual(results[0]['support_oppose_indicator'], 'o')
26 changes: 11 additions & 15 deletions webservices/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,32 +742,28 @@ def make_seek_args(field=fields.Int, description=None):
}

schedule_e = {
'candidate_office': fields.List(fields.Str(validate=validate.OneOf(['', 'H', 'S', 'P'])), description=docs.OFFICE),
'candidate_office': fields.List(fields.Str(validate=validate.OneOf(['', 'H', 'S', 'P'])),
description=docs.OFFICE),
'candidate_party': fields.List(IStr, description=docs.PARTY),
'candidate_office_state': fields.List(IStr, description=docs.STATE_GENERIC),
'candidate_office_district': fields.List(District, description=docs.DISTRICT),
'cycle': fields.List(fields.Int, description=docs.RECORD_CYCLE),
'committee_id': fields.List(IStr, description=docs.COMMITTEE_ID),
'candidate_id': fields.List(IStr, description=docs.CANDIDATE_ID),
'filing_form': fields.List(IStr, description='Filing form'),
'filing_form': fields.List(IStr, description=docs.FORM_TYPE),
'last_expenditure_date': fields.Date(missing=None,
description='When sorting by `expenditure_date`,'
'this is populated with the `expenditure_date` of the last result.'
'However, you will need to pass the index of that last result to `last_index` to get the next page.'),
description=docs.LAST_EXPENDITURE_DATE),
'last_expenditure_amount': fields.Float(missing=None,
description='When sorting by `expenditure_amount`,'
'this is populated with the `expenditure_amount` of the last result.'
'However, you will need to pass the index of that last result to `last_index` to get the next page.'),
description=docs.LAST_EXPENDITURE_AMOUNT),
'last_office_total_ytd': fields.Float(missing=None,
description='When sorting by `office_total_ytd`,'
'this is populated with the `office_total_ytd` of the last result.'
'However, you will need to pass the index of that last result to `last_index` to get the next page.'),
'payee_name': fields.List(fields.Str, description='Name of the entity that received the payment'),
description=docs.LAST_OFFICE_TOTAL_YTD),
'payee_name': fields.List(fields.Str, description=docs.PAYEE_NAME),
'support_oppose_indicator': fields.List(
IStr(validate=validate.OneOf(['S', 'O'])),
description='Support or opposition',
),
'is_notice': fields.List(fields.Bool, description='Record filed as 24- or 48-hour notice'),
description=docs.SUPPORT_OPPOSE_INDICATOR),
'last_support_oppose_indicator': fields.Str(missing=None,
description=docs.LAST_SUPPOSE_OPPOSE_INDICATOR),
'is_notice': fields.List(fields.Bool, description=docs.IS_NOTICE),
}

schedule_e_efile = {
Expand Down
37 changes: 37 additions & 0 deletions webservices/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1286,3 +1286,40 @@ def add_ytd(var):
MAX_TRANSACTION_DATA_COMPLETE_DATE = '''
Select all filings processed completely before this date
'''

LAST_EXPENDITURE_DATE = '''
When sorting by `expenditure_date`,
this is populated with the `expenditure_date` of the last result.
However, you will need to pass the index of that last result to
`last_index` to get the next page.
'''

LAST_EXPENDITURE_AMOUNT = '''
When sorting by `expenditure_amount`,
this is populated with the `expenditure_amount` of the last result.
However, you will need to pass the index of that last result to
`last_index` to get the next page.
'''
LAST_OFFICE_TOTAL_YTD = '''
When sorting by `office_total_ytd`,
this is populated with the `office_total_ytd` of the last result.
However, you will need to pass the index of that last result to
`last_index` to get the next page.'
'''

LAST_SUPPOSE_OPPOSE_INDICATOR = '''
When sorting by `support_oppose_indicator`,
this is populated with the `support_oppose_indicator` of the last result.
However, you will need to pass the index of that last result to `last_index`
to get the next page.'
'''

PAYEE_NAME = '''
Name of the entity that received the payment.
'''
IS_NOTICE = '''
Record filed as 24- or 48-hour notice.
'''
filing_form = '''
The form type filed by the canidate of committee
'''
1 change: 1 addition & 0 deletions webservices/resources/sched_e.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def args(self):
'expenditure_date',
'expenditure_amount',
'office_total_ytd',
'support_oppose_indicator'
]),
),
)
Expand Down