geonode.facets.models

Attributes

DEFAULT_FACET_PAGE_SIZE

FACET_TYPE_PLACE

FACET_TYPE_USER

FACET_TYPE_THESAURUS

FACET_TYPE_CATEGORY

FACET_TYPE_BASE

FACET_TYPE_KEYWORD

logger

facet_registry

Classes

FacetProvider

Provides access to the facet information and the related topics

FacetsRegistry

Module Contents

geonode.facets.models.DEFAULT_FACET_PAGE_SIZE = 10[source]
geonode.facets.models.FACET_TYPE_PLACE = 'place'[source]
geonode.facets.models.FACET_TYPE_USER = 'user'[source]
geonode.facets.models.FACET_TYPE_THESAURUS = 'thesaurus'[source]
geonode.facets.models.FACET_TYPE_CATEGORY = 'category'[source]
geonode.facets.models.FACET_TYPE_BASE = 'base'[source]
geonode.facets.models.FACET_TYPE_KEYWORD = 'keyword'[source]
geonode.facets.models.logger[source]
class geonode.facets.models.FacetProvider(**kwargs)[source]

Provides access to the facet information and the related topics

config[source]
__str__()[source]
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

class geonode.facets.models.FacetsRegistry[source]
facet_providers = None[source]
_load_facets_configuration() None[source]

Facet loading is done lazily because some FacetProvider may need to access the DB, which may not have been initialized/created yet

register_facet_provider(provider: FacetProvider)[source]
get_providers()[source]
get_provider(name)[source]
geonode.facets.models.facet_registry[source]