summaryrefslogtreecommitdiffstats
path: root/views/pages.py
diff options
context:
space:
mode:
authorAamir Khan <syst3m.w0rm@gmail.com>2012-06-25 00:39:31 -0400
committerAamir Khan <syst3m.w0rm@gmail.com>2012-06-25 00:39:31 -0400
commitd136299d02c154c0fc8fd79f2f56af8c4def63e3 (patch)
treee95f2954e27949f1394b45d19b38679c5dea23a1 /views/pages.py
parent90d32cc679d0943cb1d24aca0e1837e15a7b7563 (diff)
downloadhyperkitty-d136299d02c154c0fc8fd79f2f56af8c4def63e3.tar.gz
hyperkitty-d136299d02c154c0fc8fd79f2f56af8c4def63e3.tar.xz
hyperkitty-d136299d02c154c0fc8fd79f2f56af8c4def63e3.zip
populate voteup/votedown for each message
Diffstat (limited to 'views/pages.py')
-rw-r--r--views/pages.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/views/pages.py b/views/pages.py
index 879c30a..8f682f0 100644
--- a/views/pages.py
+++ b/views/pages.py
@@ -21,6 +21,8 @@ from django.contrib.auth.decorators import (login_required,
user_passes_test)
from kittystore.kittysastore import KittySAStore
+from gsoc.models import Rating
+
from thread import AddTagForm
logger = logging.getLogger(__name__)
@@ -88,7 +90,6 @@ def add_category(request, mlist_fqdn, email_id):
else:
form = AddCategoryForm()
c = RequestContext(request, {
- 'app_name': settings.APP_NAME,
'list_address': mlist_fqdn,
'email_id': email_id,
'addtag_form': form,
@@ -365,10 +366,31 @@ def thread (request, mlist_fqdn, threadid):
participants = {}
cnt = 0
- for msg in threads:
- msg.email = msg.email.strip()
+ for message in threads:
+ message.email = message.email.strip()
+ # Extract all the votes for this message
+ try:
+ votes = Rating.objects.filter(messageid = message.message_id)
+ except Rating.DoesNotExist:
+ votes = {}
+
+ likes = 0
+ dislikes = 0
+
+ for vote in votes:
+ if vote.vote == 1:
+ likes = likes + 1
+ elif vote.vote == -1:
+ dislikes = dislikes + 1
+ else:
+ pass
+
+ message.votes = votes
+ message.likes = likes
+ message.dislikes = dislikes
+
# Statistics on how many participants and threads this month
- participants[msg.sender] = {'email': msg.email}
+ participants[message.sender] = {'email': message.email}
cnt = cnt + 1
archives_length = STORE.get_archives_length(list_name)
@@ -377,7 +399,6 @@ def thread (request, mlist_fqdn, threadid):
print dir(search_form)
c = RequestContext(request, {
- 'app_name': settings.APP_NAME,
'list_name' : list_name,
'list_address': mlist_fqdn,
'search_form': search_form,