Exemple #1
0
 def setup_table(self):
     table_id = self.table_id or get_table_id(self.fields)
     try:
         self.table = get_datatable(table_id).get_db_table(year=self.release_year)
         self.stdout.write("Table for fields %s is %s" % (self.fields, self.table.id))
     except KeyError:
         raise CommandError("Couldn't establish which table to use for these fields. Have you added a FieldTable entry in youthexporer/tables.py?\nFields: %s" % self.fields)
Exemple #2
0
 def setup_table(self):
     table_id = self.table_id or get_table_id(self.fields)
     try:
         self.table = get_datatable(table_id).get_db_table(year=self.release_year)
         self.stdout.write("Table for fields %s is %s" % (self.fields, self.table.id))
     except KeyError:
         raise CommandError("Couldn't establish which table to use for these fields. Have you added a FieldTable entry in wazimap_za/tables.py?\nFields: %s" % self.fields)
Exemple #3
0
 def setup_table(self):
     table_id = self.table_id or get_table_id(self.fields)
     try:
         self.table = get_datatable(table_id)
         self.stdout.write("Table for fields %s is %s" %
                           (self.fields, self.table.id))
     except KeyError:
         raise CommandError(
             "Couldn't establish which table to use for these fields. "
             "Have you added a FieldTable entry in wazimap_za/tables.py?\nFields: %s"
             % self.fields)
Exemple #4
0
def get_crime_profile(geo, session):
    child_crime, total = get_stat_data(
        ['crime'], geo, session,
        only=['Neglect and ill-treatment of children'],
        percent=False)

    table = get_datatable(get_table_id(['crime']))

    return {
        'dataset': table.dataset_name,
        'crime_against_children': {
            'name': 'Crimes of neglect and ill-treatment of children in 2014',
            'values': {'this': total},
            'metadata': {'universe': 'Crimes in 2014'},
        },
    }
Exemple #5
0
def get_crime_profile(geo_code, geo_level, session):
    child_crime, total = get_stat_data(
        ['crime'], geo_level, geo_code, session,
        only=['Neglect and ill-treatment of children'],
        percent=False)

    table = get_datatable(get_table_id(['crime']))

    return {
        'dataset': table.dataset_name,
        'crime_against_children': {
            'name': 'Crimes of neglect and ill-treatment of children in 2014',
            'values': {'this': total},
            'metadata': {'universe': 'Crimes in 2014'},
        },
    }