def tag_article_cloud(parser, token): from tagging.templatetags.tagging_tags import do_tag_cloud_for_model from datetime import datetime token_copy = token.contents.split() token_copy.insert(1, 'articles.Article') l = len(token_copy) - 1 for i in range(0, l): token_copy.insert(i * 2 + 1, ' ') token.contents = ''.join(token_copy) filters = {'status': 'published', 'publish_date__lte': datetime.now()} TagsForModelNode = do_tag_cloud_for_model(parser, token, filters) return TagsForModelNode
def tag_article_cloud(parser, token): from tagging.templatetags.tagging_tags import do_tag_cloud_for_model from datetime import datetime token_copy = token.contents.split() token_copy.insert(1, 'articles.Article') l = len(token_copy) - 1 for i in range(0, l): token_copy.insert(i*2+1, ' ') token.contents = ''.join(token_copy) filters = { 'status' : 'published', 'publish_date__lte' : datetime.now()} TagsForModelNode = do_tag_cloud_for_model(parser, token, filters) return TagsForModelNode
def do_tag_cloud_for_entries(parser, token): """ A wrapper around ``tagging.templatetags.do_tag_cloud_for_model`` which add a filter to exclude draft entries from ``QuerySet``. This template tag retrieves a list of ``Tag`` objects for a Entry model, with tag cloud attributes set, and stores them in a context variable. Usage:: {% tag_cloud_for_entries as [varname] %} Extended usage:: {% tag_cloud_for_entries as [varname] with [options] %} Extra options can be provided after an optional ``with`` argument, with each option being specified in ``[name]=[value]`` format. Valid extra options are: ``steps`` Integer. Defines the range of font sizes. ``min_count`` Integer. Defines the minimum number of times a tag must have been used to appear in the cloud. ``distribution`` One of ``linear`` or ``log``. Defines the font-size distribution algorithm to use when generating the tag cloud. Examples:: {% tag_cloud_for_entries as entries_tags %} {% tag_cloud_for_entries as entries_tags with steps=9 min_count=3 distribution=log %} """ token.contents = token.contents.replace( 'tag_cloud_for_entries', 'tag_cloud_for_model diario.Entry', 1 ) node = do_tag_cloud_for_model(parser, token) node.kwargs['filters'] = {'is_draft': False} return node
def do_tag_cloud_for_entries(parser, token): """ A wrapper around ``tagging.templatetags.do_tag_cloud_for_model`` which add a filter to exclude draft entries from ``QuerySet``. This template tag retrieves a list of ``Tag`` objects for a Entry model, with tag cloud attributes set, and stores them in a context variable. Usage:: {% tag_cloud_for_entries as [varname] %} Extended usage:: {% tag_cloud_for_entries as [varname] with [options] %} Extra options can be provided after an optional ``with`` argument, with each option being specified in ``[name]=[value]`` format. Valid extra options are: ``steps`` Integer. Defines the range of font sizes. ``min_count`` Integer. Defines the minimum number of times a tag must have been used to appear in the cloud. ``distribution`` One of ``linear`` or ``log``. Defines the font-size distribution algorithm to use when generating the tag cloud. Examples:: {% tag_cloud_for_entries as entries_tags %} {% tag_cloud_for_entries as entries_tags with steps=9 min_count=3 distribution=log %} """ token.contents = token.contents.replace( 'tag_cloud_for_entries', 'tag_cloud_for_model diario.Entry', 1) node = do_tag_cloud_for_model(parser, token) node.kwargs['filters'] = {'is_draft': False} return node