diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-06-18 16:30:38 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-06-18 16:30:38 +0200 |
commit | 5924b67e6716be1530436dd986ddb941125fa5e3 (patch) | |
tree | 299f4e209b6f9a0f524375af527c49423077b698 /hyperkitty/lib | |
parent | c8f2ecc0476b0caf2c8a87033c5ffcdf6ac6263b (diff) | |
download | hyperkitty-5924b67e6716be1530436dd986ddb941125fa5e3.tar.gz hyperkitty-5924b67e6716be1530436dd986ddb941125fa5e3.tar.xz hyperkitty-5924b67e6716be1530436dd986ddb941125fa5e3.zip |
Add Top Posters and Popular Threads widgets to the overview
Diffstat (limited to 'hyperkitty/lib')
-rw-r--r-- | hyperkitty/lib/voting.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/hyperkitty/lib/voting.py b/hyperkitty/lib/voting.py index 7d7cc64..8624d75 100644 --- a/hyperkitty/lib/voting.py +++ b/hyperkitty/lib/voting.py @@ -23,14 +23,16 @@ from hyperkitty.models import Rating -def get_votes(message_id_hash, user=None): +def get_votes(msgid, user=None): """Extract all the votes for this message""" - likes = dislikes = 0 + likes = dislikes = myvote = 0 try: - votes = Rating.objects.filter(messageid=message_id_hash) + if isinstance(msgid, basestring): + votes = Rating.objects.filter(messageid=msgid) + elif isinstance(msgid, list): + votes = Rating.objects.filter(messageid__in=msgid) except Rating.DoesNotExist: votes = {} - myvote = 0 for vote in votes: if vote.vote == 1: likes += 1 |