[#1894] Fix convert_to_extras to allow use with normal extras

`convert_to_extras` was adding the custom fields in an unflattened way
during validation to the object that would be later unflattened. This
worked fine if there were only `convert_to_extras` fields, but not if
you were also providing actual extras, eg

    data_dict = {
        'name': 'test-dataset',
        'custom_text': 'Hi',
        'custom_text2': 'Hi2',
        'extras': [
            {'key': 'proper_extra', 'value': 'Bye'},
        ]

    }

This fixes the `convert_to_extras` output and adds new converters test for it.
[#1894] Move test files to proper place

Moved functional tests to ckan/new_tests/logic/test_conversion.py and
added new unit tests for `convert_to_extras` to
ckan/new_tests/logic/test_converters.py
[#1894] Pass a list of keys in the schema to validators

This is included in the context. We pass a copy of the one provided to
validate.
[#1894] Prevent free extras to have the same key as a schema field

Added a new validator to the 'key' field of the extras schema that
checks if the value is present on the 'schema_fields' list that was
added to the context on the previous commit.
[#1894] (Partially) Fix the error_summary for extras validation errors

If there is a validation error on the extras, the error summary would
*always* be `Missing Value`. I guess it was assumed that all validation
errors would be that the extra key was missing. The fix is not ideal, as
it still assumes that all errors will be on the 'key' field (there could
be custom validation on the value), but at least it will show more than
one error, and the ones different from `Missing Value`.

This can furhter be improved, eg changing the macro that renders the
error summary on the templates to allow lists of errors, and maybe
showing the error below the actual extra field (using the index?)
[#1894] Update docs and example_idatasetform to reflect changes

For the 2.2.1 branch, only changes in the snippet were added, as the docs page
does not exist here
[#1894] Simplify conversion tests

Don't load `example_idatasetform` as this causes failures in other
tests. Rather pass a schema directly.
[#1882] Fix org link in dataset page

Replaced use of `with` in the snippet.

Conflicts:
	ckan/templates/snippets/organization.html
[#1917] Check only for active org memberships

When returning the list of organizations that a user belongs to return
only the organizations that they currently belong to - not orgs that
they were previously a member of.
[#1879] Set DataStore to legacy mode when using PostgreSQL < 9.x

Up until now the user had to actively set legacy mode when running PG
8.x, and if not you could end up with the full datastore running on an
old postgres version. Features like the SQL search are not properly
supported on these versions, so we need to explicitly disable them when
running on PG 8.x, by setting `legacy_mode` to True.

The current behaviour is that legacy mode will be activated if
`ckan.datastore.read_url` is not present in the configuration and/or
postgres < 9.x.
[#1879] Fix tests

The travis setup explicitly removes the `ckan.datastore.read_url`
setting when running the tests, so we need to use a dummy one.

Also some refactoring
[#1871] Add function to extract table names from SQL statement

The function performs an EXPLAIN query with the provided statement and
parses its output looking for table names. It requires Postgres >= 9.x,
as it uses the FORMAT JSON option to get and parse a JSON objects.
 [#1871] Disallow DataStore SQL queries involving system tables

 Using the `get_table_names_from_sql` helper function before running the
 provided statement, we raise a Validation error if some of the tables
 start with `pg_`.
[#1871] Fix tests

PEP9 and skip the get table names tests if running on legacy mode.

Conflicts:
	ckanext/datastore/tests/test_helpers.py
[#1871] Fix wrong call in tests
[#1902] Don't show private datasets to group members

1. User Sean creates organization my-org
2. Sean adds private dataset my-dataset to my-org
3. Sean creates group my-group
4. Sean adds private dataset my-dataset to my-group
5. Sean adds user Fred to my-group
6. The group_show API will now show the private dataset my-dataset to
   Fred, even though Fred is not a member of my-org.

For some reason the private dataset does not show on the group's page,
but it does show in ther API.

This commit removes it from the API.

If backported this commit will also fix a problem present on 2.2 and
2.2.1 (but not master) that after following the steps above Fred will
see the private dataset on the site front page.

Arguably you should not be able to add private datasets to groups at
all, but you could add a public dataset to a group and then make the
dataset private and it would still belong to the group, so we do need to
filter private datasets out of groups.

Conflicts:
	ckan/lib/dictization/model_dictize.py
[#1902] Test that group_show() doesn't show private datasets

Conflicts:
	ckan/new_tests/logic/action/test_get.py
[#1902] PEP8
Update test factories with the latest version from master

Otherwise is really difficult to keep tests on this branch up to date
[#1697] Don't break PEP8 tests if test files have lines >79 chars

According to naming test methods [1] in our testing coding standards, we should
make the test names clear "...even if it means your method name gets really
long, since we don’t write code that calls our test methods there’s no
advantage to having short test method names".  Given this, we shouldn't
validate E501 on our test suite.

[1] https://ckan.readthedocs.org/en/latest/contributing/testing.html#naming-test-methods