Exemplo n.º 1
0
    def get_context_data(self, filtered_ids):
        selected_tag_slugs = []

        if self.value:
            selected_tags = TagService.get_by_slugs(self.value)
            selected_tag_slugs = [tag.slug for tag in selected_tags]

        all_tags = TagService.get_tag_cloud()
        filtered_tags = TagService.get_filtered_tag_cloud(filtered_ids)

        # mark selected
        for tag in all_tags:
            # tag is selected
            if selected_tag_slugs and (tag.slug in selected_tag_slugs):
                tag.selected = True

            try:
                tag.count = filtered_tags.get(id=tag.id).count
            except Tag.DoesNotExist:
                tag.disabled = True
                tag.count = 0

        context = {"tag_cloud": all_tags}
        return context
Exemplo n.º 2
0
 def get_context_data(self, **kwargs):
     context = super(TagsList, self).get_context_data(**kwargs)
     context['categories'] = TagService.get_category_tag_cloud()
     context['page'] = 'tags_page'
     return context