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

Add national party schedule a/b endpoints #5791

Merged
merged 5 commits into from
May 15, 2024
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
18 changes: 18 additions & 0 deletions tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,3 +651,21 @@ class Meta:
class TotalsInauguralDonationsFactory(BaseFactory):
class Meta:
model = models.InauguralDonations


class NationalParty_ScheduleAFactory(BaseFactory):
class Meta:
model = models.NationalParty_ScheduleA

sub_id = factory.Sequence(lambda n: n)
report_year = 2024
two_year_transaction_period = 2024


class NationalParty_ScheduleBFactory(BaseFactory):
class Meta:
model = models.NationalParty_ScheduleB

sub_id = factory.Sequence(lambda n: n)
report_year = 2024
two_year_transaction_period = 2024
468 changes: 468 additions & 0 deletions tests/test_national_party.py

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions webservices/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,3 +1347,94 @@ def make_seek_args(field=fields.Int, description=None):
'contributor_name': fields.List(IStr, description=docs.CONTRIBUTOR_NAME),
'cycle': fields.List(fields.Int(), description=docs.COMMITTEE_CYCLE)
}

# Used for endpoint `/national_party/schedule_a/`
# 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,
),
'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),
'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=docs.CONTRIBUTOR_TYPE
),
'contributor_committee_type': fields.List(
IStr(validate=validate.OneOf([
'', 'C', 'D', 'E', 'H', 'I', 'N', 'O', 'P', 'Q',
'S', 'U', 'V', 'W', 'X', 'Y', 'Z'])),
description=docs.COMMITTEE_TYPE,
),
'contributor_committee_designation': fields.List(
IStr(validate=validate.OneOf(['', 'A', 'J', 'P', 'U', 'B', 'D'])),
description=docs.DESIGNATION,
),
'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=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=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),
'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),
'recipient_state': fields.List(IStr, description=docs.RECIPIENT_STATE),
'recipient_zip': fields.List(IStr, description=docs.RECIPIENT_ZIP),
'recipient_committee_designation': fields.List(
IStr(validate=validate.OneOf(['', 'A', 'J', 'P', 'U', 'B', 'D'])),
description=docs.DESIGNATION,
),
'recipient_committee_type': fields.List(
IStr(validate=validate.OneOf([
'', 'C', 'D', 'E', 'H', 'I', 'N', 'O', 'P', 'Q',
'S', 'U', 'V', 'W', 'X', 'Y', 'Z'])),
description=docs.COMMITTEE_TYPE,
),
'two_year_transaction_period': fields.List(
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,
),
}
1 change: 1 addition & 0 deletions webservices/common/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
from .audit import * # noqa
from .operations_log import * # noqa
from .presidential import * # noqa
from .national_party import * # noqa
201 changes: 201 additions & 0 deletions webservices/common/models/national_party.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
from .base import db
from sqlalchemy.dialects.postgresql import TSVECTOR
from webservices import docs


class NationalParty_ScheduleA(db.Model):
__table_args__ = {'schema': 'public'}
__tablename__ = 'ofec_sched_a_national_party_mv'

amendment_indicator = db.Column('action_cd', db.String)
amendment_indicator_desc = db.Column('action_cd_desc', db.String)
back_reference_schedule_name = db.Column('back_ref_sched_nm', db.String)
back_reference_transaction_id = db.Column('back_ref_tran_id', db.String)
candidate_id = db.Column('cand_id', db.String, doc=docs.CANDIDATE_ID)
candidate_middle_name = db.Column('cand_m_nm', db.String)
candidate_name = db.Column('cand_nm', db.String, doc=docs.CANDIDATE_NAME)
candidate_first_name = db.Column('cand_nm_first', db.String)
candidate_last_name = db.Column('cand_nm_last', db.String)
candidate_office = db.Column('cand_office', db.String)
candidate_office_full = db.Column('cand_office_desc', db.String)
candidate_office_district = db.Column('cand_office_district', db.String, doc=docs.DISTRICT)
candidate_office_state = db.Column('cand_office_st', db.String)
candidate_office_state_full = db.Column('cand_office_st_desc', db.String)
candidate_prefix = db.Column('cand_prefix', db.String)
candidate_suffix = db.Column('cand_suffix', db.String)
contributor_committee_name = db.Column('contbr_cmte', db.String)
contributor_committee_designation = db.Column('contbr_cmte_desgn', db.String)
contributor_committee_designation_full = db.Column('contbr_cmte_desgn_full', db.String)
contributor_committee_organization = db.Column('contbr_cmte_org', db.String)
contributor_committee_organization_full = db.Column('contbr_cmte_org_full', db.String)
contributor_committee_party = db.Column('contbr_cmte_party', db.String)
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, 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)
committee_name = db.Column('cmte_nm', db.String, doc=docs.COMMITTEE_NAME)
recipient_committee_type = db.Column('cmte_tp', db.String, doc=docs.COMMITTEE_TYPE)
recipient_committee_type_full = db.Column('committee_type_full', db.String)
contributor_aggregate_ytd = db.Column('contb_aggregate_ytd', db.Numeric(14, 2))
contribution_receipt_amount = db.Column('contb_receipt_amt', db.Numeric(14, 2))
contribution_receipt_date = db.Column('contb_receipt_dt', db.Date)
contributor_city = db.Column('contbr_city', db.String, index=True, doc=docs.CONTRIBUTOR_CITY)
contributor_employer = db.Column('contbr_employer', db.String, index=True, doc=docs.CONTRIBUTOR_EMPLOYER)
contributor_employer_text = db.Column(TSVECTOR)
contributor_id = db.Column('clean_contbr_id', db.String, index=True, doc=docs.CONTRIBUTOR_ID)
contributor_middle_name = db.Column('contbr_m_nm', db.String)
contributor_name = db.Column('contbr_nm', db.String, index=True)
contributor_name_text = db.Column(TSVECTOR)
contributor_first_name = db.Column('contbr_nm_first', db.String)
contributor_last_name = db.Column('contbr_nm_last', db.String)
contributor_occupation = db.Column('contbr_occupation', db.String(38), index=True)
contributor_occupation_text = db.Column(TSVECTOR)
contributor_prefix = db.Column('contbr_prefix', db.String)
contributor_state = db.Column('contbr_st', db.String, index=True, doc=docs.CONTRIBUTOR_STATE)
contributor_street_1 = db.Column('contbr_st1', db.String)
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)
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)
election_type = db.Column('election_tp', db.String)
election_type_desc = db.Column('election_tp_desc', db.String)
entity_type = db.Column('entity_tp', db.String)
entity_type_desc = db.Column('entity_tp_desc', db.String)
fec_election_type_desc = db.Column('fec_election_tp_desc', db.String)
fec_election_year = db.Column('fec_election_yr', db.String)
file_number = db.Column('file_num', db.Numeric)
filing_form = db.Column(db.String)
filing_frequency = db.Column(db.String)
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)
is_individual = db.Column(db.Boolean)
line_num = db.Column(db.String)
line_number_label = db.Column(db.String)
link_id = db.Column(db.String)
memo_cd = db.Column(db.String)
memo_cd_desc = db.Column(db.String)
memo_text = db.Column(db.String)
national_cmte_nonfed_acct = db.Column(db.String)
orig_sub_id = db.Column(db.Numeric)
party = db.Column(db.String)
party_account_type = db.Column('party_account', db.String)
party_full = db.Column(db.String)
pdf_url = db.Column(db.String)
receipt_desc = db.Column('receipt_desc', db.String)
receipt_type = db.Column('receipt_tp', db.String)
receipt_type_desc = db.Column('receipt_tp_desc', db.String)
report_type = db.Column('rpt_tp', db.String)
report_year = db.Column('rpt_yr', db.Numeric, index=True)
schedule_type = db.Column(db.String)
schedule_type_desc = db.Column(db.String)
state = db.Column(db.String)
state_full = db.Column(db.String)
sub_id = db.Column(db.Numeric(19), primary_key=True, index=True)
tran_id = db.Column(db.String)
treasurer_name = db.Column(db.String)
two_year_transaction_period = db.Column(db.Numeric)


class NationalParty_ScheduleB(db.Model):
__table_args__ = {'schema': 'public'}
__tablename__ = 'ofec_sched_b_national_party_mv'

amendment_indicator = db.Column('action_cd', db.String)
amendment_indicator_desc = db.Column('action_cd_desc', db.String)
back_reference_schedule_id = db.Column('back_ref_sched_id', db.String)
back_reference_transaction_id = db.Column('back_ref_tran_id', db.String)
benef_committee_name = db.Column('benef_cmte_nm', db.String)
candidate_id = db.Column('cand_id', db.String, doc=docs.CANDIDATE_ID)
candidate_middle_name = db.Column('cand_m_nm', db.String)
candidate_name = db.Column('cand_nm', db.String, doc=docs.CANDIDATE_NAME)
candidate_first_name = db.Column('cand_nm_first', db.String)
candidate_last_name = db.Column('cand_nm_last', db.String)
candidate_office = db.Column('cand_office', db.String)
candidate_office_full = db.Column('cand_office_desc', db.String)
candidate_office_district = db.Column('cand_office_district', db.String, doc=docs.DISTRICT)
candidate_office_state = db.Column('cand_office_st', db.String)
candidate_office_state_full = db.Column('cand_office_st_desc', db.String)
candidate_prefix = db.Column('cand_prefix', db.String)
candidate_suffix = db.Column('cand_suffix', db.String)
category_code = db.Column('catg_cd', db.String)
category_code_desc = db.Column('catg_cd_desc', db.String)
spender_committee_designation = db.Column('cmte_dsgn', db.String)
committee_id = db.Column('cmte_id', db.String(9), doc=docs.COMMITTEE_ID)
committee_name = db.Column('cmte_nm', db.String, doc=docs.COMMITTEE_NAME)
spender_committee_type = db.Column('cmte_tp', db.String, doc=docs.COMMITTEE_TYPE)
committee_type = db.Column(db.String)
committee_type_full = db.Column(db.String)
disbursement_amount = db.Column('disb_amt', db.Numeric, index=True)
disbursement_description = db.Column('disb_desc', db.String)
disbursement_date = db.Column('disb_dt', db.Date, index=True)
disbursement_type = db.Column('disb_tp', db.String)
disbursement_type_desc = db.Column('disb_tp_desc', db.String)
disbursement_description_text = db.Column(TSVECTOR)
disbursement_purpose_category = db.Column(db.String)
election_type = db.Column('election_tp', db.String)
election_type_desc = db.Column('election_tp_desc', db.String)
entity_type = db.Column('entity_tp', db.String)
entity_type_desc = db.Column('entity_tp_desc', db.String)
fec_election_type_desc = db.Column('fec_election_tp_desc', db.String)
fec_election_type_year = db.Column('fec_election_tp_year', db.String)
file_number = db.Column('file_num', db.Numeric)
filing_form = db.Column(db.String)
filing_frequency = db.Column(db.String)
image_number = db.Column('image_num', db.String(18), index=True, doc=docs.IMAGE_NUMBER)
is_active = db.Column(db.Boolean)
line_number = db.Column('line_num', db.String)
line_number_label = db.Column(db.String)
link_id = db.Column(db.String)
memo_cd = db.Column(db.String)
memo_cd_desc = db.Column(db.String)
memo_text = db.Column(db.String)
national_cmte_nonfed_acct = db.Column('national_cmte_nonfed_acct', db.String)
orig_sub_id = db.Column(db.Numeric)
party = db.Column(db.String)
party_account = db.Column('party_account', db.String)
party_full = db.Column('party_full', db.String)
payee_employer = db.Column('payee_employer', db.String)
payee_first_name = db.Column('payee_f_nm', db.String)
payee_last_name = db.Column('payee_l_nm', db.String)
payee_middle_name = db.Column('payee_m_nm', db.String)
payee_occupation = db.Column('payee_occupation', db.String)
payee_prefix = db.Column(db.String)
payee_suffix = db.Column(db.String)
pdf_url = db.Column(db.String)
recipient_city = db.Column(db.String)
recipient_committee_id = db.Column('recipient_cmte_id', db.String)
recipient_committee_name = db.Column('recipient_cmte', db.String)
recipient_committee_designation = db.Column('recipient_cmte_desgn', db.String)
recipient_committee_designation_full = db.Column('recipient_cmte_desgn_full', db.String)
recipient_committee_org = db.Column('recipient_cmte_org', db.String)
recipient_committee_org_full = db.Column('recipient_cmte_org_full', db.String)
recipient_committee_party = db.Column('recipient_cmte_party', db.String)
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, 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)
recipient_state = db.Column('recipient_st', db.String)
recipient_street1 = db.Column('recipient_st1', db.String)
recipient_street2 = db.Column('recipient_st2', db.String)
recipient_zip = db.Column('recipient_zip', db.String)
ref_disp_excess_flg = db.Column('ref_disp_excess_flg', db.String)
report_type = db.Column('rpt_tp', db.String)
report_year = db.Column('rpt_yr', db.Numeric, index=True)
schedule_type = db.Column(db.String)
schedule_type_desc = db.Column(db.String)
semi_an_bundled_refund = db.Column('semi_an_bundled_refund', db.Numeric)
state = db.Column(db.String)
state_full = db.Column(db.String)
sub_id = db.Column(db.Numeric(19), primary_key=True, index=True)
tran_id = db.Column(db.String)
treasurer_name = db.Column(db.String)
two_year_transaction_period = db.Column(db.Numeric)
Loading