Пример #1
0
 def pdf_url(self):
     return utils.report_pdf_url(
         self.report_year,
         self.beginning_image_number,
         committee_type=self.committee.committee_type if self.committee else None,
         form_type=self.form_type,
     )
Пример #2
0
 def test_elections(self):
     results = self._results(api.url_for(ElectionView, office='house', cycle=2012, state='NY', district='07'))
     self.assertEqual(len(results), 1)
     expected = {
         'candidate_id': self.candidate.candidate_id,
         'candidate_name': self.candidate.name,
         'incumbent_challenge_full': self.candidate.incumbent_challenge_full,
         'party_full': self.candidate.party_full,
         'committee_ids': [each.committee_id for each in self.committees],
         'total_receipts': sum(each.receipts for each in self.totals),
         'total_disbursements': sum(each.disbursements for each in self.totals),
         'cash_on_hand_end_period': sum(each.last_cash_on_hand_end_period for each in self.totals),
         'document_description': utils.document_description(
             self.totals[1].last_report_year,
             self.totals[1].last_report_type_full,
         ),
         'pdf_url': utils.report_pdf_url(
             self.totals[1].last_report_year,
             self.totals[1].last_beginning_image_number,
             'F3',
             'S',
         ),
         'won': False,
     }
     self.assertEqual(results[0], expected)
Пример #3
0
 def pdf_url(self):
     return utils.report_pdf_url(
         self.report_year,
         self.beginning_image_number,
         committee_type=self.committee.committee_type
         if self.committee else None,
         form_type=self.form_type,
     )
Пример #4
0
class ElectionSchema(ma.Schema):
    candidate_id = ma.fields.Str()
    candidate_name = ma.fields.Str()
    incumbent_challenge_full = ma.fields.Str()
    party_full = ma.fields.Str()
    committee_ids = ma.fields.List(ma.fields.Str)
    total_receipts = ma.fields.Decimal()
    total_disbursements = ma.fields.Decimal()
    cash_on_hand_end_period = ma.fields.Decimal()
    document_description = ma.fields.Function(
        lambda o: utils.document_description(
            o.report_year,
            o.report_type_full,
        ))
    pdf_url = ma.fields.Function(lambda o: utils.report_pdf_url(
        o.report_year,
        o.beginning_image_number,
        'F3P' if o.office == 'P' else 'F3',
        o.office[0].upper(),
    ))
Пример #5
0
 def test_elections(self):
     results = self._results(
         api.url_for(ElectionView,
                     office='house',
                     cycle=2012,
                     state='NY',
                     district='07'))
     self.assertEqual(len(results), 1)
     expected = {
         'candidate_id':
         self.candidate.candidate_id,
         'candidate_name':
         self.candidate.name,
         'incumbent_challenge_full':
         self.candidate.incumbent_challenge_full,
         'party_full':
         self.candidate.party_full,
         'committee_ids': [each.committee_id for each in self.committees],
         'total_receipts':
         sum(each.receipts for each in self.totals),
         'total_disbursements':
         sum(each.disbursements for each in self.totals),
         'cash_on_hand_end_period':
         sum(each.last_cash_on_hand_end_period for each in self.totals),
         'document_description':
         utils.document_description(
             self.totals[1].last_report_year,
             self.totals[1].last_report_type_full,
         ),
         'pdf_url':
         utils.report_pdf_url(
             self.totals[1].last_report_year,
             self.totals[1].last_beginning_image_number,
             'F3',
             'S',
         ),
         'won':
         False,
     }
     self.assertEqual(results[0], expected)