Skip to content

Commit

Permalink
Add doc descriptions to SA filters
Browse files Browse the repository at this point in the history
  • Loading branch information
pkfec committed Apr 25, 2024
1 parent 00b9576 commit a522d31
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 44 deletions.
2 changes: 1 addition & 1 deletion tests/test_national_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def test_filter_party_account_type(self):
class TestNationalPartyScheduleB(ApiBaseTest):
kwargs = {'two_year_transaction_period': 2024}

def test_schedule_b_multiple_two_year_transaction_period(self):
def test_multiple_two_year_transaction_period(self):
"""
testing schedule_b api can take multiple cycles now
"""
Expand Down
49 changes: 25 additions & 24 deletions webservices/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -1349,35 +1349,27 @@ def make_seek_args(field=fields.Int, description=None):
}

# Used for endpoint `/national_party/schedule_a/`
# under tag: national party
# under tag: national party accounts
national_party_schedule_a = {
'committee_id': fields.List(Committee_ID, description=docs.COMMITTEE_ID),
'contributor_id': fields.List(IStr, description=docs.CONTRIBUTOR_ID),
'two_year_transaction_period': fields.List(
TwoYearTransactionPeriod,
description=docs.TWO_YEAR_TRANSACTION_PERIOD,
),
'min_date': Date(description='Minimum date'),
'max_date': Date(description='Maximum date'),
'contributor_name': fields.List(Keyword, description=docs.CONTRIBUTOR_NAME),
'contributor_city': fields.List(IStr, description=docs.CONTRIBUTOR_CITY),
'contributor_state': fields.List(IStr, description=docs.CONTRIBUTOR_STATE),
'contributor_zip': fields.List(IStr, description=docs.CONTRIBUTOR_ZIP),
'contributor_occupation': fields.List(Keyword, description=docs.CONTRIBUTOR_OCCUPATION),
'contributor_employer': fields.List(Keyword, description=docs.CONTRIBUTOR_EMPLOYER),
'image_number': fields.List(IStr, description=docs.IMAGE_NUMBER),
'contribution_receipt_date': Date(
missing=None,
description=' Filter by contribution receipt date '
),
'contribution_receipt_amount': fields.Float(
missing=None,
description='Filter by contribution receipt amount'
),
'min_contribution_receipt_date': Date(description=docs.MIN_RECEIPT_DATE),
'max_contribution_receipt_date': Date(description=docs.MAX_RECEIPT_DATE),
'is_individual': fields.Bool(missing=None, description=docs.IS_INDIVIDUAL),
'contributor_type': fields.List(
fields.Str(validate=validate.OneOf(['individual', 'committee'])),
description='Filters individual or committee contributions based on line number'
description=docs.CONTRIBUTOR_TYPE
),
'contributor_committee_type': fields.List(
IStr(validate=validate.OneOf([
Expand All @@ -1389,30 +1381,39 @@ def make_seek_args(field=fields.Int, description=None):
IStr(validate=validate.OneOf(['', 'A', 'J', 'P', 'U', 'B', 'D'])),
description=docs.DESIGNATION,
),
'min_amount': Currency(description='Filter for all amounts greater than a value.'),
'max_amount': Currency(description='Filter for all amounts less than a value.'),
'min_contribution_receipt_amount': Currency(description=docs.MIN_RECEIPT_AMOUNT),
'max_contribution_receipt_amount': Currency(description=docs.MAX_RECEIPT_AMOUNT),
'party_account_type': fields.List(
IStr(validate=validate.OneOf(['', 'CONVENTION', 'HEADQUARTERS', 'RECOUNT'])),
description='National party account type',
description=docs.NATIONAL_PARTY_ACCOUNT_TYPE,
),
'receipt_type': fields.List(
IStr(validate=validate.OneOf([
'30', '30E', '30F', '30G', '30J', '30K', '30T',
'31', '31E', '31F', '31G', '31J', '31K', '31T',
'32', '32E', '32F', '32G', '32J', '32K', '32T'])),
description='National party account receipt type',
description=docs.RECEIPT_TYPE_CODES
),
}

# Used for endpoint `/national_party/schedule_b/`
# under tag: national party accounts
national_party_schedule_b = {
'committee_id': fields.List(Committee_ID, description=docs.COMMITTEE_ID),
'disbursement_type': fields.List(
IStr(validate=validate.OneOf([
'40', '40T', '40Y', '40Z', '41', '41T', '41Y',
'41Z', '42', '42T', '42Y', '42Z'])),
description=docs.DISBURSEMENT_TYPE_CODES
),
'disbursement_description': fields.List(Keyword, description=docs.DISBURSEMENT_DESCRIPTION),
'disbursement_purpose_category': fields.List(IStr(validate=validate.OneOf(disbursment_purpose_list)),
description=docs.DISBURSEMENT_PURPOSE_CATEGORY),
'disbursement_amount': fields.Float(missing=None, description=docs.LAST_DISBURSEMENT_AMOUNT),
'disbursement_date': Date(missing=None, description=docs.LAST_DISBURSEMENT_DATE),
# 'line_number': fields.List(IStr, description=docs.LINE_NUMBER),
'line_number': fields.Str(description=docs.LINE_NUMBER),
'line_number': fields.Str(description=docs.NATIONAL_PARTY_SB_LINE_NUMBER),
'min_disbursement_amount': Currency(description=docs.MIN_DISBURSEMENT_AMOUNT),
'max_disbursement_amount': Currency(description=docs.MAX_DISBURSEMENT_AMOUNT),
'min_disbursement_date': Date(description=docs.MIN_DISBURSEMENT_DATE),
'max_disbursement_date': Date(description=docs.MAX_DISBURSEMENT_DATE),
'recipient_city': fields.List(IStr, description=docs.RECIPIENT_CITY),
'recipient_committee_id': fields.List(Committee_ID, description=docs.RECIPIENT_COMMITTEE_ID),
'recipient_name': fields.List(Keyword, description=docs.RECIPIENT_NAME),
Expand All @@ -1421,10 +1422,6 @@ def make_seek_args(field=fields.Int, description=None):
IStr(validate=validate.OneOf(['', 'A', 'J', 'P', 'U', 'B', 'D'])),
description=docs.DESIGNATION,
),
'spender_committee_org_type': fields.List(
IStr(validate=validate.OneOf(['', 'C', 'L', 'M', 'T', 'V', 'W'])),
description=docs.ORGANIZATION_TYPE,
),
'spender_committee_type': fields.List(
IStr(validate=validate.OneOf([
'', 'C', 'D', 'E', 'H', 'I', 'N', 'O', 'P', 'Q',
Expand All @@ -1435,4 +1432,8 @@ def make_seek_args(field=fields.Int, description=None):
TwoYearTransactionPeriod,
description=docs.TWO_YEAR_TRANSACTION_PERIOD,
),
'party_account_type': fields.List(
IStr(validate=validate.OneOf(['', 'CONVENTION', 'HEADQUARTERS', 'RECOUNT'])),
description=docs.NATIONAL_PARTY_ACCOUNT_TYPE,
),
}
7 changes: 2 additions & 5 deletions webservices/common/models/national_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NationalParty_ScheduleA(db.Model):
contributor_committee_party_full = db.Column('contbr_cmte_party_full', db.String)
contributor_committee_state = db.Column('contbr_cmte_state', db.String)
contributor_committee_state_full = db.Column('contbr_cmte_state_full', db.String)
contributor_committee_type = db.Column('contbr_cmte_type', db.String)
contributor_committee_type = db.Column('contbr_cmte_type', db.String, index=True)
contributor_committee_type_full = db.Column('contbr_cmte_type_full', db.String)
committee_designation = db.Column('cmte_dsgn', db.String)
committee_id = db.Column('cmte_id', db.String(9), doc=docs.COMMITTEE_ID)
Expand Down Expand Up @@ -67,7 +67,6 @@ class NationalParty_ScheduleA(db.Model):
contributor_street_2 = db.Column('contbr_st2', db.String)
contributor_suffix = db.Column('contbr_suffix', db.String)
contributor_zip = db.Column('contbr_zip', db.String, index=True, doc=docs.CONTRIBUTOR_ZIP)
# check with helen, if this is recepient committee designation
recipient_committee_designation = db.Column('designation', db.String)
recipient_committee_designation_full = db.Column('designation_full', db.String)
donor_committee_name = db.Column('donor_cmte_nm', db.String)
Expand All @@ -80,8 +79,6 @@ class NationalParty_ScheduleA(db.Model):
file_number = db.Column('file_num', db.Numeric)
filing_form = db.Column(db.String)
filing_frequency = db.Column(db.String)
first_f1_date = db.Column(db.Date)
first_file_date = db.Column(db.Date)
image_number = db.Column('image_num', db.String(18), index=True, doc=docs.IMAGE_NUMBER)
increased_limit = db.Column(db.String)
is_active = db.Column(db.Boolean)
Expand Down Expand Up @@ -201,7 +198,7 @@ class NationalParty_ScheduleB(db.Model):
recipient_committee_party_full = db.Column('recipient_cmte_party_full', db.String)
recipient_committee_state = db.Column('recipient_cmte_state', db.String)
recipient_committee_state_full = db.Column('recipient_cmte_state_full', db.String)
recipient_committee_type = db.Column('recipient_cmte_type', db.String)
recipient_committee_type = db.Column('recipient_cmte_type', db.String, index=True)
recipient_committee_type_full = db.Column('recipient_cmte_type_full', db.String)
recipient_name_text = db.Column(TSVECTOR)
recipient_name = db.Column('recipient_nm', db.String)
Expand Down
90 changes: 86 additions & 4 deletions webservices/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2442,14 +2442,96 @@ def add_ytd(var):
'''

NATIONAL_PARTY = '''
Collection of these endpoints provide information about national party account receipts and disbursements
NATIONAL_PARTY_ACCOUNTS = '''
Collection of endpoints that provide information about national party committee accounts
including presidential nominating conventions, national party headquarters buildings,
and election recounts and contests and other legal proceedings accounts.
'''

NATIONAL_PARTY_SCHED_A = '''
This endpoint includes national party account receipts
This endpoint includes national party committee account receipts for presidential nominating conventions,
national party headquarters buildings, and election recounts and contests and other legal proceedings accounts.
'''

NATIONAL_PARTY_SCHED_B = '''
This endpoint includes national party account disbursements
This endpoint includes national party committee account disbursements for presidential nominating conventions,
national party headquarters buildings, and election recounts and contests and other legal proceedings accounts
'''

RECEIPT_TYPE_CODES = 'National party account transaction codes for receipts:\n\
-30 CONVENTION ACCOUNT RECEIPT - INDIVIDUAL\n\
-30E EARMARKED – CONVENTION\n\
-30F MEMO RECEIPT FROM REGISTERED FILER - JF CONVENTION ACCOUNT\n\
-30G TRANSFER IN - CONVENTION ACCOUNT\n\
-30J MEMO RECEIPT FROM INDIVIDUAL - JF CONVENTION ACCOUNT\n\
-30K CONVENTION ACCOUNT RECEIPT - REGISTERED FILER\n\
-30T CONVENTION ACCOUNT RECEIPT - TRIBAL\n\
-31 HEADQUARTERS ACCOUNT RECEIPT- INDIVIDUAL\n\
-31E EARMARKED – HEADQUARTERS\n\
-31F MEMO RECEIPT FROM REGISTERED FILER - JF HEADQUARTERS ACCOUNT\n\
-31G TRANSFER IN - HEADQUARTERS ACCOUNT\n\
-31J MEMO RECEIPT FROM INDIVIDUAL - JF HEADQUARTERS ACCOUNT\n\
-31K HEADQUARTERS ACCOUNT RECEIPT - REGISTERED FILER\n\
-31T HEADQUARTERS ACCOUNT RECEIPT - TRIBAL\n\
-32 RECOUNT ACCOUNT RECEIPT- INDIVIDUAL\n\
-32E EARMARKED – RECOUNT\n\
-32F MEMO RECEIPT FROM REGISTERED FILER - JF RECOUNT ACCOUNT\n\
-32G TRANSFER IN - RECOUNT ACCOUNT\n\
-32J MEMO RECEIPT FROM INDIVIDUAL - JF RECOUNT ACCOUNT\n\
-32K RECOUNT ACCOUNT RECEIPT- REGISTERED FILER\n\
-32T RECOUNT ACCOUNT RECEIPT - TRIBAL\n\
'
NATIONAL_PARTY_ACCOUNT_TYPE = 'Type of national party account:\n\
- CONVENTION\n\
- HEADQUARTERS\n\
- RECOUNT\n\
'
CONTRIBUTOR_TYPE = '''
Filters individual or committee contributions based on line number
'''

MIN_RECEIPT_AMOUNT = '''
Minimum receipts amount
'''

MAX_RECEIPT_AMOUNT = '''
Maximum receipts amount
'''
RECEIPT_AMOUNT = '''
Filter by contributions of any amount received by committees
'''

DISBURSEMENT_TYPE_CODES = 'National party account transaction codes for disbursements:\n\
-40 CONVENTION ACCOUNT DISBURSEMENT\n\
-40T CONVENTION ACCOUNT REFUND - TRIBAL\n\
-40Y CONVENTION ACCOUNT REFUND - INDIVIDUAL\n\
-40Z CONVENTION ACCOUNT REFUND - REGISTERED FILER\n\
-41 HEADQUARTERS ACCOUNT DISBURSEMENT\n\
-41T HEADQUARTERS ACCOUNT REFUND - TRIBAL\n\
-41Y HEADQUARTERS ACCOUNT REFUND - INDIVIDUAL\n\
-41Z HEADQUARTERS ACCOUNT REFUND - REGISTERED FILER\n\
-42 RECOUNT ACCOUNT DISBURSEMENT\n\
-42T RECOUNT ACCOUNT REFUND - TRIBAL\n\
-42Y RECOUNT ACCOUNT REFUND - INDIVIDUAL\n\
-42Z RECOUNT ACCOUNT REFUND - REGISTERED FILER\n\
'
NATIONAL_PARTY_SB_LINE_NUMBER = '''Filter for form and line number using the following format:
`<form_number-line_number>`. For example F3X-21b or F3X-29 would filter
down to all entries from form `F3X` and line number `21b` or form `F3X` and line number `29`.
'''

MIN_DISBURSEMENT_DATE = '''
Selects all disbursements received after this date(MM/DD/YYYY or YYYY-MM-DD)
'''

MAX_DISBURSEMENT_DATE = '''
Selects all disbursements received before this date(MM/DD/YYYY or YYYY-MM-DD)
'''

MIN_DISBURSEMENT_AMOUNT = '''
Minimum disbursement amount
'''

MAX_DISBURSEMENT_AMOUNT = '''
Maximum disbursement amount
'''
14 changes: 8 additions & 6 deletions webservices/resources/national_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# under tag: national party
# Ex: http://127.0.0.1:5000/v1/national_party/schedule_a/
@doc(
tags=['national party'],
tags=['national party accounts'],
description=docs.NATIONAL_PARTY_SCHED_A,
)
class NationalParty_ScheduleAView(ApiResource):
Expand Down Expand Up @@ -58,8 +58,10 @@ class NationalParty_ScheduleAView(ApiResource):
]

filter_range_fields = [
(('min_date', 'max_date'), models.NationalParty_ScheduleA.contribution_receipt_date),
(('min_amount', 'max_amount'), models.NationalParty_ScheduleA.contribution_receipt_amount),
(('min_contribution_receipt_date', 'max_contribution_receipt_date'),
models.NationalParty_ScheduleA.contribution_receipt_date),
(('min_contribution_receipt_amount', 'max_contribution_receipt_amount'),
models.NationalParty_ScheduleA.contribution_receipt_amount),
]

@property
Expand Down Expand Up @@ -98,7 +100,7 @@ def build_query(self, **kwargs):
# under tag: national party
# Ex: http://127.0.0.1:5000/v1/national_party/schedule_b/
@doc(
tags=['national party'],
tags=['national party accounts'],
description=docs.NATIONAL_PARTY_SCHED_B,
)
class NationalParty_ScheduleBView(ApiResource):
Expand Down Expand Up @@ -138,8 +140,8 @@ class NationalParty_ScheduleBView(ApiResource):
]

filter_range_fields = [
(('min_amount', 'max_amount'), models.NationalParty_ScheduleB.disbursement_amount),
(('min_date', 'max_date'), models.NationalParty_ScheduleB.disbursement_date),
(('min_disbursement_amount', 'max_disbursement_amount'), models.NationalParty_ScheduleB.disbursement_amount),
(('min_disbursement_date', 'max_disbursement_date'), models.NationalParty_ScheduleB.disbursement_date),
]

@property
Expand Down
8 changes: 4 additions & 4 deletions webservices/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ def format_docstring(docstring):
'name': 'committee',
'description': format_docstring(docs.COMMITTEE_TAG),
},
{
'name': 'national party',
'description': format_docstring(docs.NATIONAL_PARTY),
},
{
'name': 'dates',
'description': format_docstring(docs.DATES_TAG),
Expand Down Expand Up @@ -87,6 +83,10 @@ def format_docstring(docstring):
'name': 'filer resources',
'description': format_docstring(docs.FILER_RESOURCES),
},
{
'name': 'national party accounts',
'description': format_docstring(docs.NATIONAL_PARTY_ACCOUNTS),
},
{
'name': 'efiling',
'description': format_docstring(docs.EFILING_TAG),
Expand Down

0 comments on commit a522d31

Please sign in to comment.