Skip to content

Commit

Permalink
Merge pull request #15 from nigma/patch-1
Browse files Browse the repository at this point in the history
Check for user.is_authenticated() is a function call.
  • Loading branch information
chrisglass committed Mar 6, 2012
2 parents 826e794 + 38e29e5 commit 250a10a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions rulez/templatetags/rulez_perms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django import template
from django.contrib.auth.models import AnonymousUser

register = template.Library()

Expand All @@ -12,8 +11,6 @@ def __init__(self, codename, objname, varname):
def render(self, context):
user_obj = template.resolve_variable('user', context)
obj = template.resolve_variable(self.objname, context)
if not user_obj.is_authenticated:
user_obj = AnonymousUser()
context[self.varname] = user_obj.has_perm(self.codename, obj)
return ''

Expand Down Expand Up @@ -47,6 +44,6 @@ def rulez_perms(parser, token):
if bits[3] != 'as':
raise template.TemplateSyntaxError(
"third argument to tag must be 'as'")
return RulezPermsNode(bits[1], bits[2], bits[3])
return RulezPermsNode(bits[1], bits[2], bits[4])

rulez_perms = register.tag(rulez_perms)

0 comments on commit 250a10a

Please sign in to comment.