WorldBank-Transport/open-transit-indicators — pull request #63 by ddohler (2014-07-23 19:17:02+00:00)
Title: Demographic data backend

This adds a number of classes to track demographic data:
- DemographicDataSource: A shapefile providing demographic data
- DemographicDataSourceProblem: A Problem with a DemographicDataSource
- DemographicDataFieldName: The fields available for import from a
DemographicDataSource
- DemographicDataFeature: Stores the values of the fields chosen by
the user along with their associated geometries.
- OTIDemographicConfig: The configuration of the app regarding which
fields from the shapefile are being used for indicator calculations.

It also adds two Celery tasks for dealing with shapefiles containing
demographic data:
- get_shapefile_fields: Generates DemographicDataFieldName objects based
on the field names found in the shapefile, but does not import any
data.
- load_shapefile_data: Loads the data specified by the user from the
shapefile into the database; creates DemographicDataFeature objects.
Removes any existing data before running, so only one set of data can
exist in the database at any given time.

Since this is kind of large, here's an outline of the workflow I have in mind for using this from the front-end:
1. POST shapefile to `/demographics/`
2. Poll for processing status, present any errors to user.
3. Read `fields` array from processed shapefile, present to user.
4. After user selects which fields to use, POST to `/demographics//load/` with the user's selection (as a JSON representation of an `OTIDemographicConfig` object).
5. Poll for processing status
6. Present any errors / warnings to the user.

It's possible to step through this from the DRF API console, although it's a bit clunky.