Exemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(CoaccusedSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'id': get('officer_id'),
         'full_name': self.get_full_name,
         'abbr_name': self.get_abbr_name,
         'gender': get_gender('officer__gender'),
         'race': get('officer__race'),
         'rank': get('officer__rank'),
         'final_outcome': get('final_outcome'),
         'final_finding': get_finding('final_finding', 'Unknown'),
         'recc_outcome': get('recc_outcome'),
         'category': get('allegation_category__category'),
         'subcategory': get('allegation_category__allegation_name'),
         'start_date': get_date('start_date'),
         'end_date': get_date('end_date'),
         'age': self.get_age,
         'allegation_count': get('allegation_count'),
         'sustained_count': get('sustained_count'),
         'disciplined': get('disciplined'),
         'percentile_allegation': get('officer__complaint_percentile'),
         'percentile_allegation_civilian': get('officer__civilian_allegation_percentile'),
         'percentile_allegation_internal': get('officer__internal_allegation_percentile'),
         'percentile_trr': get('officer__trr_percentile')
     }
Exemplo n.º 2
0
    def test_get_date(self):
        expect(
            get_date('start_date')({'start_date': date(2016, 4, 5)})
        ).to.eq('2016-04-05')

        expect(
            get_date('start_date')({'start_date': None})
        ).to.be.none()
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     super(OfficerSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'id': get('id'),
         'full_name': self.get_full_name,
         'unit': self.get_unit,
         'rank': get('rank'),
         'race': get('race'),
         'badge': self.get_current_badge,
         'badge_keyword': self.get_current_badge,
         'historic_badges': self.get_historic_badges,
         'historic_badges_keyword': self.get_historic_badges,
         'historic_units': self.get_historic_units,
         'gender': get_gender('gender'),
         'date_of_appt': get_date('appointed_date'),
         'date_of_resignation': get_date('resignation_date'),
         'active': self.get_active,
         'birth_year': get('birth_year'),
         'complaint_records': self.get_complaint_records,
         'allegation_count': get('complaint_count'),
         'complaint_percentile': get('complaint_percentile'),
         'civilian_allegation_percentile':
         get('civilian_allegation_percentile'),
         'internal_allegation_percentile':
         get('internal_allegation_percentile'),
         'trr_percentile': get('trr_percentile'),
         'honorable_mention_percentile':
         get('honorable_mention_percentile'),
         'honorable_mention_count': self.get_honorable_mention_count,
         'has_visual_token': self.get_has_visual_token,
         'sustained_count': get('sustained_complaint_count'),
         'discipline_count': get('discipline_complaint_count'),
         'civilian_compliment_count': self.get_civilian_compliment_count,
         'trr_count': get('annotated_trr_count'),
         'major_award_count': self.get_major_award_count,
         'tags': get('tags'),
         'to': self.get_to,
         'url': self.get_url,
         'current_salary': self.get_current_salary,
         'unsustained_count': get('unsustained_complaint_count'),
         'coaccusals': self.get_coaccusals,
         'current_allegation_percentile':
         self.get_current_allegation_percentile,
         'percentiles': get('percentiles'),
         'cr_incident_dates': self.get_cr_incident_dates,
         'trr_datetimes': self.get_trr_datetimes,
     }
 def __init__(self, *args, **kwargs):
     super(UnitChangeNewTimelineSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'officer_id': get('officer_id'),
         'date_sort': get('effective_date'),
         'priority_sort': literal(20),
         'date': get_date('effective_date'),
         'kind': literal('UNIT_CHANGE'),
         'unit_name': get('unit_name'),
         'unit_description': get('unit_description'),
         'rank': get('rank')
     }
 def __init__(self, *args, **kwargs):
     super(RankChangeNewTimelineSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'officer_id': get('officer_id'),
         'date_sort': get('spp_date'),
         'priority_sort': literal(25),
         'date': get_date('spp_date'),
         'kind': literal('RANK_CHANGE'),
         'unit_name': get('unit_name', ''),
         'unit_description': get('unit_description', ''),
         'rank': get('rank')
     }
Exemplo n.º 6
0
 def __init__(self, *args, **kwargs):
     super(JoinedNewTimelineSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'officer_id': get('id'),
         'date_sort': get('appointed_date'),
         'priority_sort': literal(10),
         'date': get_date('appointed_date'),
         'kind': literal('JOINED'),
         'unit_name': get('unit_name'),
         'unit_description': get('unit_description'),
         'rank': get('rank')
     }
 def __init__(self, *args, **kwargs):
     super(AwardNewTimelineSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'officer_id': get('officer_id'),
         'date_sort': get('start_date'),
         'priority_sort': literal(40),
         'date': get_date('start_date'),
         'kind': literal('AWARD'),
         'award_type': get('award_type'),
         'unit_name': get('unit_name'),
         'unit_description': get('unit_description'),
         'rank': get('rank')
     }
 def __init__(self, *args, **kwargs):
     super(TRRNewTimelineSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'trr_id': get('id'),
         'officer_id': get('officer_id'),
         'date_sort': self.get_date_sort,
         'priority_sort': literal(50),
         'date': get_date('trr_datetime'),
         'kind': literal('FORCE'),
         'taser': get('taser'),
         'firearm_used': get('firearm_used'),
         'unit_name': get('unit_name'),
         'unit_description': get('unit_description'),
         'rank': get('rank'),
         'point': get_point('point')
     }
Exemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     super(AllegationSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'crid': get('crid'),
         'most_common_category': self.get_most_common_category,
         'coaccused': CoaccusedSerializer(key='coaccused'),
         'summary': get('summary'),
         'point': get_point('point'),
         'incident_date': get_date('incident_date'),
         'start_date': self.get_any_start_date,
         'end_date': self.get_any_end_date,
         'address': self.get_address,
         'location': get('location'),
         'beat': get('beat__name'),
         'involvements': self.get_involvements,
         'category_names': self.get_categories,
         'complainants': DemographicSerializer(key='complainants'),
         'victims': DemographicSerializer(key='victims'),
         'attachments': AttachmentSerializer(key='attachments')
     }
Exemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     super(CRNewTimelineSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'officer_id': get('officer_id'),
         'date_sort': self._get_date_sort,
         'priority_sort': literal(30),
         'date': get_date('incident_date'),
         'kind': literal('CR'),
         'crid': get('crid'),
         'category': get('allegation_category__category'),
         'subcategory': get('allegation_category__allegation_name'),
         'finding': get_finding('final_finding', 'Unknown'),
         'outcome': get('final_outcome'),
         'coaccused': get('annotated_coaccused_count'),
         'unit_name': get('unit_name', ''),
         'unit_description': get('unit_description', ''),
         'rank': get('rank'),
         'victims': _VictimSerializer('victims'),
         'attachments': _AttachmentSerializer('attachments'),
         'point': get_point('point')
     }