From 3c6f9c0885a95de8081b43e1fa145417b09c9a82 Mon Sep 17 00:00:00 2001 From: Priya Kasireddy Date: Wed, 24 Apr 2024 21:35:51 -0400 Subject: [PATCH] Add doc descriptions to SA filters --- webservices/args.py | 41 +++++----- webservices/common/models/national_party.py | 7 +- webservices/docs.py | 90 ++++++++++++++++++++- webservices/resources/national_party.py | 14 ++-- webservices/spec.py | 8 +- 5 files changed, 121 insertions(+), 39 deletions(-) diff --git a/webservices/args.py b/webservices/args.py index 8dd5c03ad0..458ca005dd 100644 --- a/webservices/args.py +++ b/webservices/args.py @@ -1349,7 +1349,7 @@ 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), @@ -1357,8 +1357,6 @@ def make_seek_args(field=fields.Int, description=None): 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), @@ -1366,18 +1364,12 @@ def make_seek_args(field=fields.Int, description=None): '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([ @@ -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), diff --git a/webservices/common/models/national_party.py b/webservices/common/models/national_party.py index b5813380ca..80b9ca5ef7 100644 --- a/webservices/common/models/national_party.py +++ b/webservices/common/models/national_party.py @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/webservices/docs.py b/webservices/docs.py index 9c1517455b..60a4e3a30c 100644 --- a/webservices/docs.py +++ b/webservices/docs.py @@ -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: +``. 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 ''' diff --git a/webservices/resources/national_party.py b/webservices/resources/national_party.py index 77b969b0c5..ac6a029486 100644 --- a/webservices/resources/national_party.py +++ b/webservices/resources/national_party.py @@ -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): @@ -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 @@ -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): @@ -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 diff --git a/webservices/spec.py b/webservices/spec.py index 07e36d6b64..571922b96f 100644 --- a/webservices/spec.py +++ b/webservices/spec.py @@ -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), @@ -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),