[ckan-dev] Additional Filter Abilities
Niall Beard
niall.beard at manchester.ac.uk
Mon Feb 23 11:38:11 UTC 2015
A solution could be to make liberal use of helper methods. Just create some
methods that filter as you wish in an extension, e.g:
def filter_by_blah(datasets):
for i in range(len(datasets)):
datasets.delete(i) if datasets[i].key != criteria
return datasets
Them implement iTemplateHelpers and add your methods to the hash.
http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.plugins.interfaces.ITemplateHelpers
e.g.
def get_helpers():
return {'filter_by_blah' : filter_by_blah}
Then call the helper in your view (e.g. h.filter_by_blah(datasets)). This
will return the filtered and/or ordered set of resources that you've
implemented it to return. You can filter by anything using helpers, not
just datasets of course
Niall Beard
Scientific Web Technologist,
myGrid Team,
University of Manchester
On 20 February 2015 at 19:15, Gerace, Christian [ITSUS] <cgerace at its.jnj.com
> wrote:
> Hey Community,
>
>
>
> I’ve been searching around but I can’t find an answer, so I was hoping
> someone here might know. Is there a way, or an extension, that allows a
> user to filter within the preview interface on fields using different
> comparisons (rather than just equal to)? For example, if a user wanted to
> find rows in which field 1 is not equal to “certain value”? Or even to
> compare a date, say filter rows which field 2 is greater than “2/20/15”? I
> know that this is possible via the SQL search in the API, but I was hoping
> there was a way to do this on the resource preview page.
>
>
>
> Thanks,
>
> *Christian Gerace*
> Associate Analyst - Enterprise Architect
> +1.908.655.4147 | *cgerace at its.jnj.com <cgerace at its.jnj.com>*
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150223/3b93e467/attachment-0003.html>
More information about the ckan-dev
mailing list