Beispiel #1
0
 def build_query(self, committee_id=None, **kwargs):
     query = super().build_query(committee_id=committee_id, **kwargs)
     election_full = kwargs.get('election_full')
     if election_full and not (kwargs.get('candidate_id')
                               or kwargs.get('office')):
         raise exceptions.ApiError(
             'Must include "candidate_id" or "office" argument(s)',
             status_code=422,
         )
     cycle_column = (models.CandidateElection.cand_election_year
                     if election_full else self.model.cycle)
     query = filters.filter_election(query, kwargs, self.model.candidate_id,
                                     cycle_column)
     query = query.filter(
         cycle_column.in_(kwargs['cycle']) if kwargs.get('cycle') else True)
     if election_full:
         query = self.aggregate_cycles(query, cycle_column)
     return self.join_entity_names(query)
Beispiel #2
0
 def _build_query(self, committee_id, kwargs):
     query = super()._build_query(committee_id, kwargs)
     return filters.filter_election(query, kwargs, self.model.candidate_id,
                                    self.model.cycle)