Allow origin * on read api errors

Set Access-Control-Allow-Origin header to * when the read API errors.
This is to allow easier debugging in spotlight.

This was originally going to be done in Nginx, however, on investigation
it was discovered that we'd need a non-standard module to add headers to
the response. This was a simpler route.
Merge pull request #344 from alphagov/cors-on-error

Allow origin * on read api errors
Remove duplication in the staleness check
Merge pull request #345 from alphagov/feature/dry-staleness-check

Remove duplication in the staleness check
Add tests for flatten parameter
Add new 'flatten' parameter
Rename sort_all() to sort_subgroups()
Change timeseries() to use itertools.groupby

This is necessary so that we can work with flat as well as nested data
Add FlatData, PeriodFlatData classes and flat_merge()

These mirror their grouped/nested counterparts. It should be relatively
straightforward to strip out the grouped/nested code in the future when
Backdrop changes to only return flattened responses.
Remove duplicated branch test
Tests for a new schema validation method which returns multiple errors

As a step towards giving the client more information about schema errors
we need to return all errors, not just the first. They can then fix all
the errors at once and resend the data/re upload.
Working code for returning all schema validation errors

Draft4 is the latest schema spec.

We will only return the message for now. On a future iteration we may
want to construct more detailed errors from the Exception attributes
other than message the json schema library provides.
Integration type test of dataset store - excercises multiple error paths

fixes other tests for this new pattern.

These errors may later become dicts with a location attribute.
This will specify the problematic part of the data.

These errors will be dumped to json and returned to the client as a list
of strings for now
Refactor store to return errors if problems and skip store.

Returns empty list if no problems.

Operations of data which validate or change records will return lists of
tuples
Tests for auto id stuff handling tuple response
Code and doctest fixes for returning tuples

Also slightly better error messages

Tests data set store tests should now pass.
Add mock handling store and returning errors to write integration tests

Should now be ready to refactor write to handle the new response from
store

This also expects incorrect headers to return an list of one errors.
This should help us handle things consistently. It begs the question
though. Should empty and create also return lists of errors? - will
entail more changes than just backdrop and pp-admin.
Refactor write to handle error list rather than validationerror

Still catch no data exception separately

Also returns error list for incorrect headers
pep 8 suggested fix

This reads slightly more clearly.
Handle multiple messages to prepare for tim suggested change

we will now use jsonify with multiple messages.

Is this right? and what's the deal with response data having a status?