def get_facet_blurb_facet(request): filters = get_filters(request) facet_blurb_facet = None site_config = get_site_config(request) if site_config.browse_facet_show and filters['facet_slug']: facet_slugs = filters['facet_slug'].split('/') active_facets = helpers.standard_facets_by_name_slug(facet_slugs) active_facets = list(set(active_facets)) # Set the facet blurb only if we have exactly one # CustomFacet applied. if len(active_facets) == 1 and active_facets[0].blurb: facet_blurb_facet = active_facets[0] return facet_blurb_facet
def get_custom_facet_counts(request): custom_facet_counts = [] filters = get_filters(request) querystring = get_query_string(request) site_config = get_site_config(request) if site_config.browse_facet_show: cached_custom_facets = cache.get_custom_facets(request, filters=filters, query_string=querystring) if not filters['facet_slug']: custom_facet_counts = cached_custom_facets else: facet_slugs = filters['facet_slug'].split('/') active_facets = helpers.standard_facets_by_name_slug(facet_slugs) custom_facet_counts = [(facet, count) for facet, count in cached_custom_facets if facet not in active_facets] return custom_facet_counts
def get_custom_facet_counts(request): custom_facet_counts = [] filters = get_filters(request) querystring = get_query_string(request) site_config = get_site_config(request) if site_config.browse_facet_show: cached_custom_facets = cache.get_custom_facets( request, filters=filters, query_string=querystring) if not filters['facet_slug']: custom_facet_counts = cached_custom_facets else: facet_slugs = filters['facet_slug'].split('/') active_facets = helpers.standard_facets_by_name_slug(facet_slugs) custom_facet_counts = [(facet, count) for facet, count in cached_custom_facets if facet not in active_facets] return custom_facet_counts
def build_custom_facet_breadcrumbs_from_slugs(self): ending_slug = settings.SLUG_TAGS['facet_slug'] if self.filters.get('facet_slug'): facet_filters = self.filters['facet_slug'].strip('/') facet_filters = facet_filters.split('/') custom_facets = helpers.standard_facets_by_name_slug(facet_filters) # If there's at most one path that we can remove, then # remove the ending slug as well. new_path = self.path if len(custom_facets) < 2: new_path = new_path.replace(ending_slug, '') self.custom_facet_breadcrumbs = [] for facet in custom_facets: path_for_facet = new_path.replace("/%s" % facet.name_slug, '') kwargs = { 'breadcrumb_class': 'facet_bread_box', 'display_title': facet.name, 'url': self._make_url(path=path_for_facet) } self.custom_facet_breadcrumbs.append(self.Breadcrumb(**kwargs)) self._make_clear_breadcrumb()
def build_custom_facet_breadcrumbs_from_slugs(self): ending_slug = settings.SLUG_TAGS["facet_slug"] if self.filters.get("facet_slug"): facet_filters = self.filters["facet_slug"].strip("/") facet_filters = facet_filters.split("/") custom_facets = helpers.standard_facets_by_name_slug(facet_filters) # If there's at most one path that we can remove, then # remove the ending slug as well. new_path = self.path if len(custom_facets) < 2: new_path = new_path.replace(ending_slug, "") self.custom_facet_breadcrumbs = [] for facet in custom_facets: path_for_facet = new_path.replace("/%s" % facet.name_slug, "") kwargs = { "breadcrumb_class": "facet_bread_box", "display_title": facet.name, "url": self._make_url(path=path_for_facet), } self.custom_facet_breadcrumbs.append(self.Breadcrumb(**kwargs)) self._make_clear_breadcrumb()
def build_custom_facet_breadcrumbs_from_slugs(self): ending_slug = settings.SLUG_TAGS['facet_slug'] if self.filters.get('facet_slug'): facet_filters = self.filters['facet_slug'].strip('/') facet_filters = facet_filters.split('/') custom_facets = helpers.standard_facets_by_name_slug(facet_filters) # If there's at most one path that we can remove, then # remove the ending slug as well. new_path = self.path if len(custom_facets) < 2: new_path = new_path.replace(ending_slug, '') self.custom_facet_breadcrumbs = [] for facet in custom_facets: path_for_facet = new_path.replace("/%s" % facet.name_slug, '/') kwargs = { 'breadcrumb_class': 'facet_bread_box', 'display_title': facet.name, 'url': self._make_url(path=path_for_facet) } self.custom_facet_breadcrumbs.append(self.Breadcrumb(**kwargs)) self._make_clear_breadcrumb()