geonode.facets.models ===================== .. py:module:: geonode.facets.models Attributes ---------- .. autoapisummary:: geonode.facets.models.DEFAULT_FACET_PAGE_SIZE geonode.facets.models.FACET_TYPE_PLACE geonode.facets.models.FACET_TYPE_USER geonode.facets.models.FACET_TYPE_THESAURUS geonode.facets.models.FACET_TYPE_CATEGORY geonode.facets.models.FACET_TYPE_BASE geonode.facets.models.FACET_TYPE_KEYWORD geonode.facets.models.logger geonode.facets.models.facet_registry Classes ------- .. autoapisummary:: geonode.facets.models.FacetProvider geonode.facets.models.FacetsRegistry Module Contents --------------- .. py:data:: DEFAULT_FACET_PAGE_SIZE :value: 10 .. py:data:: FACET_TYPE_PLACE :value: 'place' .. py:data:: FACET_TYPE_USER :value: 'user' .. py:data:: FACET_TYPE_THESAURUS :value: 'thesaurus' .. py:data:: FACET_TYPE_CATEGORY :value: 'category' .. py:data:: FACET_TYPE_BASE :value: 'base' .. py:data:: FACET_TYPE_KEYWORD :value: 'keyword' .. py:data:: logger .. py:class:: FacetProvider(**kwargs) Provides access to the facet information and the related topics .. py:attribute:: config .. py:method:: __str__() .. py:property:: name :type: str 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 .. py:method:: get_info(lang='en', **kwargs) -> dict 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 :param lang: lanuage for label localization :return: a dict .. py:method:: get_facet_items(queryset, start: int = 0, end: int = DEFAULT_FACET_PAGE_SIZE, lang='en', topic_contains: str = None, keys: set = {}, **kwargs) -> (int, list) 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 :param queryset: the prefiltered queryset (may be filtered for authorization or other filters) :param start: int: pagination, the index of the initial returned item :param end: int: pagination, the index of the last returned item :param lang: the preferred language for the labels :param topic_contains: only returns matching topics :param keys: only returns topics with given keys, even if their count is 0 :return: a tuple int:total count of record, list of items .. py:method:: get_topics(keys: list, lang='en', **kwargs) -> list 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 :param keys: the list of the keys of the topics, as returned by the get_facet_items() method :param lang: the preferred language for the labels :return: list of items .. py:method:: register(registry, **kwargs) -> None :classmethod: Perform registration of instances of this Provider :param registry: the registry where instances shall be registered :param kwargs: other args that may be needed by Providers .. py:class:: FacetsRegistry .. py:attribute:: facet_providers :value: None .. py:method:: _load_facets_configuration() -> None Facet loading is done lazily because some FacetProvider may need to access the DB, which may not have been initialized/created yet .. py:method:: register_facet_provider(provider: FacetProvider) .. py:method:: get_providers() .. py:method:: get_provider(name) .. py:data:: facet_registry