okfn/ckan — pull request #85 by seanh (2012-08-08 18:18:09+00:00)
Title: [#2815] Fix tracking info and isopen being stripped by validate

See the ticket: http://trac.ckan.org/ticket/2815

The 'tracking_summary' and 'isopen' fields were being stripped from
package dicts by validation. Only happened when there was a schema in use
that packages dict were being validated against, e.g. when there was an
IDatasetForm plugin with a db_to_form_schema() method.

When dictizing packages, 'tracking_summary' was being added to package
dicts as a sub-dict with two keys 'total' and 'recent', but
ckan/lib/navl/dictization_functions.py:validate() does not allow package
dicts to contain sub-dicts ("Only lists of dicts can be placed against
subschema"), they can contain only single values (e.g. strings, numbers,
bools) or lists of dicts (e.g. list of tag dicts) but not single dicts.
So change the dictization of packages to add two keys
'tracking_summary_total' and 'tracking_summary_recent' instead.

Add 'tracking_summary_total', 'tracking_summary_recent' and 'isopen' to
default_package_schema() so that they do not get stripped from package
dicts during validation.

Update a few tests now that package dicts have these three new keys.