def __init__(self, *args, **kwargs): super(_VictimSerializer, self).__init__(*args, **kwargs) self._fields = { 'race': get('race'), 'gender': get_gender('gender'), 'age': get('age') }
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') }
def __init__(self, *args, **kwargs): super(DemographicSerializer, self).__init__(*args, **kwargs) self._fields = { 'gender': get_gender('gender'), 'race': get('race'), 'age': get('age') }
def test_get_gender(self): expect( get_gender('gender')({'gender': 'M'}) ).to.eq('Male') expect( get_gender('gender')({'gender': 'F'}) ).to.eq('Female') expect( get_gender('gender')({'gender': None}) ).to.be.none() expect( get_gender('gender', 'Unknown')({'gender': None}) ).to.eq('Unknown')
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') }
def transform_demographic(self, allegation): transform_gender = get_gender('gender', 'Unknown') transform_age = get_age_range([20, 30, 40, 50], 'age', 'Unknown') for complainant in allegation['complainants']: complainant['gender'] = transform_gender(complainant) complainant['age'] = transform_age(complainant) if complainant['race'] == '': complainant['race'] = 'Unknown'
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') }
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, }