aboutsummaryrefslogtreecommitdiff
path: root/tagging/templatetags
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 11:51:47 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 11:51:47 -0700
commit71ac4bf01bb5d6dad8eb77b783a0b06cf4fdeb1e (patch)
tree267cac494b95ea0918487569768a4767f96b41ab /tagging/templatetags
parentd03c8d2d2efaf848b01e96863c29f46ce3a0db21 (diff)
downloadpython-django-tagging-71ac4bf01bb5d6dad8eb77b783a0b06cf4fdeb1e.tar
python-django-tagging-71ac4bf01bb5d6dad8eb77b783a0b06cf4fdeb1e.tar.gz
Imported Upstream version 0.2.1+svn154upstream/0.2.1+svn154
Diffstat (limited to 'tagging/templatetags')
-rw-r--r--tagging/templatetags/.svn/all-wcprops17
-rw-r--r--tagging/templatetags/.svn/dir-prop-base6
-rw-r--r--tagging/templatetags/.svn/entries96
-rw-r--r--tagging/templatetags/.svn/format1
-rw-r--r--tagging/templatetags/.svn/prop-base/__init__.py.svn-base5
-rw-r--r--tagging/templatetags/.svn/prop-base/tagging_tags.py.svn-base5
-rw-r--r--tagging/templatetags/.svn/text-base/__init__.py.svn-base0
-rw-r--r--tagging/templatetags/.svn/text-base/tagging_tags.py.svn-base231
8 files changed, 0 insertions, 361 deletions
diff --git a/tagging/templatetags/.svn/all-wcprops b/tagging/templatetags/.svn/all-wcprops
deleted file mode 100644
index c3f4205..0000000
--- a/tagging/templatetags/.svn/all-wcprops
+++ /dev/null
@@ -1,17 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 44
-/svn/!svn/ver/114/trunk/tagging/templatetags
-END
-tagging_tags.py
-K 25
-svn:wc:ra_dav:version-url
-V 60
-/svn/!svn/ver/114/trunk/tagging/templatetags/tagging_tags.py
-END
-__init__.py
-K 25
-svn:wc:ra_dav:version-url
-V 55
-/svn/!svn/ver/93/trunk/tagging/templatetags/__init__.py
-END
diff --git a/tagging/templatetags/.svn/dir-prop-base b/tagging/templatetags/.svn/dir-prop-base
deleted file mode 100644
index 4cc643b..0000000
--- a/tagging/templatetags/.svn/dir-prop-base
+++ /dev/null
@@ -1,6 +0,0 @@
-K 10
-svn:ignore
-V 6
-*.pyc
-
-END
diff --git a/tagging/templatetags/.svn/entries b/tagging/templatetags/.svn/entries
deleted file mode 100644
index 3c6a555..0000000
--- a/tagging/templatetags/.svn/entries
+++ /dev/null
@@ -1,96 +0,0 @@
-9
-
-dir
-147
-http://django-tagging.googlecode.com/svn/trunk/tagging/templatetags
-http://django-tagging.googlecode.com/svn
-
-
-
-2008-01-12T02:02:01.926198Z
-114
-jonathan.buchanan
-has-props
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-83e7428b-ec2a-0410-86f2-bf466d0e5e72
-
-tagging_tags.py
-file
-
-
-
-
-2008-08-21T18:05:40.000000Z
-1deb2386b13645b6b26bc2a74e6bd6dc
-2008-01-12T02:02:01.926198Z
-114
-jonathan.buchanan
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8602
-
-__init__.py
-file
-
-
-
-
-2008-08-21T18:05:40.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2007-08-20T09:19:55.193228Z
-93
-jonathan.buchanan
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-
diff --git a/tagging/templatetags/.svn/format b/tagging/templatetags/.svn/format
deleted file mode 100644
index ec63514..0000000
--- a/tagging/templatetags/.svn/format
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/tagging/templatetags/.svn/prop-base/__init__.py.svn-base b/tagging/templatetags/.svn/prop-base/__init__.py.svn-base
deleted file mode 100644
index bdbd305..0000000
--- a/tagging/templatetags/.svn/prop-base/__init__.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-END
diff --git a/tagging/templatetags/.svn/prop-base/tagging_tags.py.svn-base b/tagging/templatetags/.svn/prop-base/tagging_tags.py.svn-base
deleted file mode 100644
index bdbd305..0000000
--- a/tagging/templatetags/.svn/prop-base/tagging_tags.py.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-END
diff --git a/tagging/templatetags/.svn/text-base/__init__.py.svn-base b/tagging/templatetags/.svn/text-base/__init__.py.svn-base
deleted file mode 100644
index e69de29..0000000
--- a/tagging/templatetags/.svn/text-base/__init__.py.svn-base
+++ /dev/null
diff --git a/tagging/templatetags/.svn/text-base/tagging_tags.py.svn-base b/tagging/templatetags/.svn/text-base/tagging_tags.py.svn-base
deleted file mode 100644
index 11d31cc..0000000
--- a/tagging/templatetags/.svn/text-base/tagging_tags.py.svn-base
+++ /dev/null
@@ -1,231 +0,0 @@
-from django.db.models import get_model
-from django.template import Library, Node, TemplateSyntaxError, Variable, resolve_variable
-from django.utils.translation import ugettext as _
-
-from tagging.models import Tag, TaggedItem
-from tagging.utils import LINEAR, LOGARITHMIC
-
-register = Library()
-
-class TagsForModelNode(Node):
- def __init__(self, model, context_var, counts):
- self.model = model
- self.context_var = context_var
- self.counts = counts
-
- def render(self, context):
- model = get_model(*self.model.split('.'))
- if model is None:
- raise TemplateSyntaxError(_('tags_for_model tag was given an invalid model: %s') % self.model)
- context[self.context_var] = Tag.objects.usage_for_model(model, counts=self.counts)
- return ''
-
-class TagCloudForModelNode(Node):
- def __init__(self, model, context_var, **kwargs):
- self.model = model
- self.context_var = context_var
- self.kwargs = kwargs
-
- def render(self, context):
- model = get_model(*self.model.split('.'))
- if model is None:
- raise TemplateSyntaxError(_('tag_cloud_for_model tag was given an invalid model: %s') % self.model)
- context[self.context_var] = \
- Tag.objects.cloud_for_model(model, **self.kwargs)
- return ''
-
-class TagsForObjectNode(Node):
- def __init__(self, obj, context_var):
- self.obj = Variable(obj)
- self.context_var = context_var
-
- def render(self, context):
- context[self.context_var] = \
- Tag.objects.get_for_object(self.obj.resolve(context))
- return ''
-
-class TaggedObjectsNode(Node):
- def __init__(self, tag, model, context_var):
- self.tag = Variable(tag)
- self.context_var = context_var
- self.model = model
-
- def render(self, context):
- model = get_model(*self.model.split('.'))
- if model is None:
- raise TemplateSyntaxError(_('tagged_objects tag was given an invalid model: %s') % self.model)
- context[self.context_var] = \
- TaggedItem.objects.get_by_model(model, self.tag.resolve(context))
- return ''
-
-def do_tags_for_model(parser, token):
- """
- Retrieves a list of ``Tag`` objects associated with a given model
- and stores them in a context variable.
-
- Usage::
-
- {% tags_for_model [model] as [varname] %}
-
- The model is specified in ``[appname].[modelname]`` format.
-
- Extended usage::
-
- {% tags_for_model [model] as [varname] with counts %}
-
- If specified - by providing extra ``with counts`` arguments - adds
- a ``count`` attribute to each tag containing the number of
- instances of the given model which have been tagged with it.
-
- Examples::
-
- {% tags_for_model products.Widget as widget_tags %}
- {% tags_for_model products.Widget as widget_tags with counts %}
-
- """
- bits = token.contents.split()
- len_bits = len(bits)
- if len_bits not in (4, 6):
- raise TemplateSyntaxError(_('%s tag requires either three or five arguments') % bits[0])
- if bits[2] != 'as':
- raise TemplateSyntaxError(_("second argument to %s tag must be 'as'") % bits[0])
- if len_bits == 6:
- if bits[4] != 'with':
- raise TemplateSyntaxError(_("if given, fourth argument to %s tag must be 'with'") % bits[0])
- if bits[5] != 'counts':
- raise TemplateSyntaxError(_("if given, fifth argument to %s tag must be 'counts'") % bits[0])
- if len_bits == 4:
- return TagsForModelNode(bits[1], bits[3], counts=False)
- else:
- return TagsForModelNode(bits[1], bits[3], counts=True)
-
-def do_tag_cloud_for_model(parser, token):
- """
- Retrieves a list of ``Tag`` objects for a given model, with tag
- cloud attributes set, and stores them in a context variable.
-
- Usage::
-
- {% tag_cloud_for_model [model] as [varname] %}
-
- The model is specified in ``[appname].[modelname]`` format.
-
- Extended usage::
-
- {% tag_cloud_for_model [model] 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_model products.Widget as widget_tags %}
- {% tag_cloud_for_model products.Widget as widget_tags with steps=9 min_count=3 distribution=log %}
-
- """
- bits = token.contents.split()
- len_bits = len(bits)
- if len_bits != 4 and len_bits not in range(6, 9):
- raise TemplateSyntaxError(_('%s tag requires either three or between five and seven arguments') % bits[0])
- if bits[2] != 'as':
- raise TemplateSyntaxError(_("second argument to %s tag must be 'as'") % bits[0])
- kwargs = {}
- if len_bits > 5:
- if bits[4] != 'with':
- raise TemplateSyntaxError(_("if given, fourth argument to %s tag must be 'with'") % bits[0])
- for i in range(5, len_bits):
- try:
- name, value = bits[i].split('=')
- if name == 'steps' or name == 'min_count':
- try:
- kwargs[str(name)] = int(value)
- except ValueError:
- raise TemplateSyntaxError(_("%(tag)s tag's '%(option)s' option was not a valid integer: '%(value)s'") % {
- 'tag': bits[0],
- 'option': name,
- 'value': value,
- })
- elif name == 'distribution':
- if value in ['linear', 'log']:
- kwargs[str(name)] = {'linear': LINEAR, 'log': LOGARITHMIC}[value]
- else:
- raise TemplateSyntaxError(_("%(tag)s tag's '%(option)s' option was not a valid choice: '%(value)s'") % {
- 'tag': bits[0],
- 'option': name,
- 'value': value,
- })
- else:
- raise TemplateSyntaxError(_("%(tag)s tag was given an invalid option: '%(option)s'") % {
- 'tag': bits[0],
- 'option': name,
- })
- except ValueError:
- raise TemplateSyntaxError(_("%(tag)s tag was given a badly formatted option: '%(option)s'") % {
- 'tag': bits[0],
- 'option': bits[i],
- })
- return TagCloudForModelNode(bits[1], bits[3], **kwargs)
-
-def do_tags_for_object(parser, token):
- """
- Retrieves a list of ``Tag`` objects associated with an object and
- stores them in a context variable.
-
- Usage::
-
- {% tags_for_object [object] as [varname] %}
-
- Example::
-
- {% tags_for_object foo_object as tag_list %}
- """
- bits = token.contents.split()
- if len(bits) != 4:
- raise TemplateSyntaxError(_('%s tag requires exactly three arguments') % bits[0])
- if bits[2] != 'as':
- raise TemplateSyntaxError(_("second argument to %s tag must be 'as'") % bits[0])
- return TagsForObjectNode(bits[1], bits[3])
-
-def do_tagged_objects(parser, token):
- """
- Retrieves a list of instances of a given model which are tagged with
- a given ``Tag`` and stores them in a context variable.
-
- Usage::
-
- {% tagged_objects [tag] in [model] as [varname] %}
-
- The model is specified in ``[appname].[modelname]`` format.
-
- The tag must be an instance of a ``Tag``, not the name of a tag.
-
- Example::
-
- {% tagged_objects comedy_tag in tv.Show as comedies %}
-
- """
- bits = token.contents.split()
- if len(bits) != 6:
- raise TemplateSyntaxError(_('%s tag requires exactly five arguments') % bits[0])
- if bits[2] != 'in':
- raise TemplateSyntaxError(_("second argument to %s tag must be 'in'") % bits[0])
- if bits[4] != 'as':
- raise TemplateSyntaxError(_("fourth argument to %s tag must be 'as'") % bits[0])
- return TaggedObjectsNode(bits[1], bits[3], bits[5])
-
-register.tag('tags_for_model', do_tags_for_model)
-register.tag('tag_cloud_for_model', do_tag_cloud_for_model)
-register.tag('tags_for_object', do_tags_for_object)
-register.tag('tagged_objects', do_tagged_objects)