geonode.facets.models
Attributes
Classes
Provides access to the facet information and the related topics |
|
Module Contents
- class geonode.facets.models.FacetProvider(**kwargs)[source]
Provides access to the facet information and the related topics
- property name: str[source]
Get the name of the facet, to be used as a key for this provider. You may want to override this method in order to have an optimized logic :return: The name of the provider as a str
- get_info(lang='en', **kwargs) dict[source]
- Get the basic info for this provider, as a dict with these keys:
‘name’: the name of the provider (the one returned by name())
‘filter’: the filtering key to be used in a filter query
‘label’: a generic label for the facet; the client should try and localize it whenever possible
‘localized_label’: a localized label for the facet (localized according to the lang param)
‘type’: the facet type (e.g. user, region, thesaurus, …)
‘hierarchical’: boolean value telling if the facet items are hierarchically organized
“order”: an optional integer suggesting the relative ordering of the facets
- Parameters:
lang – lanuage for label localization
- Returns:
a dict
- get_facet_items(queryset, start: int = 0, end: int = DEFAULT_FACET_PAGE_SIZE, lang='en', topic_contains: str = None, keys: set = {}, **kwargs)[source]
Return the items of the facets, in a tuple:
int, total number of items matched
- list, topic records. A topic record is a dict having these keys:
key: the key of the items that should be used for filtering
label: a generic label for the item; the client should try and localize it whenever possible
localized_label: a localized label for the item
count: the count of such topic in the current facet
other facet specific keys
- Parameters:
queryset – the prefiltered queryset (may be filtered for authorization or other filters)
start – int: pagination, the index of the initial returned item
end – int: pagination, the index of the last returned item
lang – the preferred language for the labels
topic_contains – only returns matching topics
keys – only returns topics with given keys, even if their count is 0
- Returns:
a tuple int:total count of record, list of items
- get_topics(keys: list, lang='en', **kwargs) list[source]
- Return the topics with the requested ids as a list
- list, topic records. A topic record is a dict having these keys:
key: the key of the items that should be used for filtering
label: a generic label for the item; the client should try and localize it whenever possible
localized_label: a localized label for the item
other facet specific keys
- Parameters:
keys – the list of the keys of the topics, as returned by the get_facet_items() method
lang – the preferred language for the labels
- Returns:
list of items