Skip to content
Browse files

add reverse to the key

  • Loading branch information...
1 parent 99b49be commit 6f0c64ce1e12842a9fbd49c076906ecd03dcfd5d @HonzaKral HonzaKral committed Jun 4, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 ella_comments/models.py
View
9 ella_comments/models.py
@@ -14,10 +14,13 @@
'check_profanities': True
}
-COMMENT_LIST_KEY = 'comments:list:%s:%s'
+COMMENT_LIST_KEY = 'comments:list:%s:%s:%d'
def get_comment_list(qs, ctype, object_pk, reverse=None):
- cache_key = COMMENT_LIST_KEY % (ctype.pk, object_pk)
+ if reverse is None:
+ reverse = getattr(settings, 'COMMENTS_REVERSED', False)
+
+ cache_key = COMMENT_LIST_KEY % (ctype.pk, object_pk, 1 if reverse else 0)
items = cache.get(cache_key)
if items is None:
if getattr(settings, 'COMMENTS_GROUP_THREADS', False):
@@ -27,7 +30,7 @@ def get_comment_list(qs, ctype, object_pk, reverse=None):
else:
items = list(qs)
- if (reverse is not None and reverse) or getattr(settings, 'COMMENTS_REVERSED', False):
+ if reverse:
items = list(reversed(items))
cache.set(cache_key, items, timeout=30)

0 comments on commit 6f0c64c

Please sign in to comment.
Something went wrong with that request. Please try again.