Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

let caller deal with queryset limiting on their own

  • Loading branch information...
commit 2d50d27d561bbbbb2cd00da01e1d93bdb1338a7f 1 parent bbf428b
@brosner brosner authored
Showing with 8 additions and 11 deletions.
  1. +1 −5 agon/models.py
  2. +6 −5 agon/templatetags/agon_tags.py
  3. +1 −1  setup.py
View
6 agon/models.py
@@ -235,7 +235,7 @@ def points_awarded(target, since=None):
).aggregate(models.Sum("points")).get("points__sum", 0)
-def fetch_top_objects(model, limit, time_limit):
+def fetch_top_objects(model, time_limit):
queryset = model.objects.all()
if time_limit is None:
@@ -258,8 +258,4 @@ def fetch_top_objects(model, limit, time_limit):
queryset = queryset.filter(num_points__isnull=False).order_by("-num_points")
- if limit is not None:
- queryset = queryset[:limit]
-
return queryset
-
View
11 agon/templatetags/agon_tags.py
@@ -91,11 +91,12 @@ def render(self, context):
if self.limit is not None:
limit = self.limit.resolve(context)
- context[self.context_var] = fetch_top_objects(
- model,
- limit,
- self.time_limit
- )
+ objs = fetch_top_objects(model, self.time_limit)
+
+ if limit is not None:
+ objs = objs[:limit]
+
+ context[self.context_var] = objs
return u""
View
2  setup.py
@@ -3,7 +3,7 @@
setup(
name = "agon",
- version = "0.1.dev18",
+ version = "0.1.dev19",
author = "Eldarion",
author_email = "development@eldarion.com",
description = "a reusable Django points, positions and levels application",
Please sign in to comment.
Something went wrong with that request. Please try again.