Permalink
Browse files

Merge branch 'master' of github.com:nathanborror/django-basic-apps

  • Loading branch information...
2 parents 04912c4 + 216d61e commit e97af4dc27e5dd59e062beba7cd0049234084c6c @nathanborror committed Aug 20, 2010
Showing with 15 additions and 0 deletions.
  1. +15 −0 basic/flagging/templatetags/flagging.py
@@ -49,6 +49,21 @@ def unflag_url(obj, slug):
})
+@register.filter
+def flagged_with(obj, slug):
+ """
+ Returns true of false based on whether the object is flagged one or more
+ times with a particular flag type.
+ """
+ content_type = ContentType.objects.get_for_model(obj)
+ flags = Flag.objects.filter(
+ flag_type__slug=slug,
+ content_type=content_type,
+ object_id=obj.pk
+ )
+ return flags.count() != 0
+
+
class GetFlags(template.Node):
def __init__(self, object_name, user, slug, varname):
self.object_name = object_name

0 comments on commit e97af4d

Please sign in to comment.