Package s3 :: Module s3filter
[frames] | no frames]

Module s3filter

source code

Framework for filtered REST requests


Copyright: 2013-2019 (c) Sahana Software Foundation

License: MIT

Requires: gluon

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Classes
  S3FilterWidget
Filter widget for interactive search forms (base class)
  S3TextFilter
Text filter widget
  S3RangeFilter
Numerical Range Filter Widget
  S3AgeFilter
  S3DateFilter
Date Range Filter Widget - use a single field or a pair of fields for start_date/end_date
  S3SliderFilter
Filter widget for Ranges which is controlled by a Slider instead of INPUTs Wraps jQueryUI's Range Slider in S3.range_slider in S3.js
  S3LocationFilter
Hierarchical Location Filter Widget
  S3MapFilter
Map filter widget Normally configured for "~.location_id$the_geom"
  S3OptionsFilter
Options filter widget
  S3HierarchyFilter
Filter widget for hierarchical types
  S3NotEmptyFilter
Filter to check for presence of any (non-None) value in a field
  S3FilterForm
Helper class to construct and render a filter form for a resource
  S3Filter
Back-end for filter forms
  S3FilterString
Helper class to render a human-readable representation of a filter query, as representation method of JSON-serialized queries in saved filters.
Functions
 
s3_get_filter_opts(tablename, fieldname="name", location_filter=False, org_filter=False, key="id", none=False, orderby=None, translate=False)
Lazy options getter - this is useful when the expected number of options is significantly smaller than the number of records to iterate through
source code
 
s3_set_default_filter(selector, value, tablename=None)
Set a default filter for selector.
source code
Function Details

s3_get_filter_opts(tablename, fieldname="name", location_filter=False, org_filter=False, key="id", none=False, orderby=None, translate=False)

source code 

Lazy options getter - this is useful when the expected number of options is significantly smaller than the number of records to iterate through

Parameters:
  • tablename - the name of the lookup table
  • fieldname - the name of the field to represent options with
  • location_filter - whether to filter the values by location
  • org_filter - whether to filter the values by root_org
  • key - the option key field (if not "id", e.g. a super key)
  • none - whether to include an option for None
  • orderby - orderby-expression as alternative to alpha-sorting of options in widget (=> set widget sort=False)
  • translate - whether to translate the values

Note: unlike the built-in reverse lookup in S3OptionsFilter, this function does *not* check whether the options are actually in use - so it can be used to enforce filter options to be shown even if there are no records matching them.

s3_set_default_filter(selector, value, tablename=None)

source code 

Set a default filter for selector.

Parameters:
  • selector - the field selector
  • value - the value, can be a dict {operator: value}, a list of values, or a single value, or a callable that returns any of these
  • tablename - the tablename