コード例 #1
0
 def __init__(self, *args, **kwargs):
     super(DemographicSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'gender': get_gender('gender'),
         'race': get('race'),
         'age': get('age')
     }
コード例 #2
0
 def __init__(self, *args, **kwargs):
     super(_VictimSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'race': get('race'),
         'gender': get_gender('gender'),
         'age': get('age')
     }
コード例 #3
0
 def __init__(self, *args, **kwargs):
     super(_UnitSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'id': get('unit_id'),
         'unit_name': get('unit__unit_name'),
         'description': get('unit__description'),
         'long_unit_name': self.get_long_unit_name
     }
コード例 #4
0
 def __init__(self, *args, **kwargs):
     super(_AttachmentSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'title': get('title'),
         'url': get('url'),
         'preview_image_url': get('preview_image_url'),
         'file_type': get('file_type')
     }
コード例 #5
0
 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')
     }
コード例 #6
0
 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')
     }
コード例 #7
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')
     }
コード例 #8
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')
     }
コード例 #9
0
 def __init__(self, *args, **kwargs):
     super(OfficerCoaccusalSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'id':
         get('id'),
         'full_name':
         self.get_full_name,
         'allegation_count':
         get('complaint_count'),
         'sustained_count':
         get('sustained_complaint_count'),
         'race':
         get('race'),
         'gender':
         get_gender('gender'),
         'birth_year':
         get('birth_year'),
         'rank':
         get('rank'),
         'percentile_allegation':
         self.get_float('complaint_percentile'),
         'percentile_allegation_civilian':
         self.get_float('civilian_allegation_percentile'),
         'percentile_allegation_internal':
         self.get_float('internal_allegation_percentile'),
         'percentile_trr':
         self.get_float('trr_percentile')
     }
コード例 #10
0
 def __init__(self, *args, **kwargs):
     super(PoliceWitnessSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'officer_id': get('officer_id'),
         'involved_type': literal('police_witness'),
         'full_name': self.get_full_name,
         'abbr_name': self.get_abbr_name,
         'allegation_count': get('allegation_count'),
         'sustained_count': get('sustained_count'),
         'gender': get_gender('officer__gender'),
         'race': get('officer__race'),
         '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')
     }
コード例 #11
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')
     }
コード例 #12
0
 def __init__(self, *args, **kwargs):
     super(InvestigatorSerializer, self).__init__(*args, **kwargs)
     self._fields = {
         'officer_id': get('investigator__officer_id'),
         'involved_type': literal('investigator'),
         'full_name': self.get_full_name,
         'abbr_name': self.get_abbr_name,
         'percentile_allegation': get('investigator__officer__complaint_percentile'),
         'percentile_allegation_civilian': get('investigator__officer__civilian_allegation_percentile'),
         'percentile_allegation_internal': get('investigator__officer__internal_allegation_percentile'),
         'percentile_trr': get('investigator__officer__trr_percentile'),
         'num_cases': get('num_cases'),
         'current_rank': get('current_rank')
     }
コード例 #13
0
 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')
     }
コード例 #14
0
 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')
     }
コード例 #15
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')
     }
コード例 #16
0
 def test_get(self):
     expect(get('name')({'name': 'Jerome'})).to.eq('Jerome')
     expect(get('name')({'age': 45})).to.eq(None)
     expect(get('name', '')({'age': 45})).to.eq('')
     expect(get('name', '')({'name': None})).to.eq('')
コード例 #17
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,
     }
コード例 #18
0
 def __init__(self, *args, **kwargs):
     super(Serializer, self).__init__(*args, **kwargs)
     self._fields = {
         'name': get('first_name')
     }