Browse files

fixed fencepost error

  • Loading branch information...
1 parent e2fd53d commit f97285309b424fcd862f54863cc95464a2c0ed6e @paltman paltman committed Feb 2, 2011
Showing with 7 additions and 1 deletion.
  1. +1 −1 agon/templatetags/agon_tags.py
  2. +6 −0 agon/tests.py
View
2 agon/templatetags/agon_tags.py
@@ -39,7 +39,7 @@ def handle_token(cls, parser, token):
)
if len(bits) == 6 or len(bits) == 9:
- if "limit" not in [bits[4], bits[7]]:
+ if "limit" != bits[4] and (len(bits) == 9 and "limit" == bits[7]):
raise template.TemplateSyntaxError(
"4th or 7th argument to %r must be 'limit'" % bits[0]
)
View
6 agon/tests.py
@@ -358,6 +358,12 @@ def test_should_return_annotated_queryset(self):
t.render(c)
self.assertEquals(c["top_users"].model, User.objects.all().model)
+ def test_should_return_annotated_queryset_with_limit(self):
+ t = Template("""{% load agon_tags %}{% top_objects "auth.User" as top_users limit 3 %}""")
+ c = Context({})
+ t.render(c)
+ self.assertEquals(c["top_users"].model, User.objects.all().model)
+
def test_should_return_annotated_queryset_non_user_model(self):
t = Template("""{% load agon_tags %}{% top_objects "auth.Group" as top_users %}""")
c = Context({})

0 comments on commit f972853

Please sign in to comment.