geonode.facets.providers.category

Attributes

logger

Classes

CategoryFacetProvider

Implements faceting for resource's topicCategory

Module Contents

geonode.facets.providers.category.logger[source]
class geonode.facets.providers.category.CategoryFacetProvider(**kwargs)[source]

Bases: geonode.facets.models.FacetProvider

Implements faceting for resource’s topicCategory

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

classmethod register(registry, **kwargs) None[source]

Perform registration of instances of this Provider

Parameters:
  • registry – the registry where instances shall be registered

  • kwargs – other args that may be needed by Providers