summaryrefslogtreecommitdiffstats
path: root/hyperkitty/views/list.py
diff options
context:
space:
mode:
Diffstat (limited to 'hyperkitty/views/list.py')
-rw-r--r--hyperkitty/views/list.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py
index 26bdbf1..d122c84 100644
--- a/hyperkitty/views/list.py
+++ b/hyperkitty/views/list.py
@@ -19,12 +19,10 @@ from django.contrib.auth.decorators import (login_required,
from hyperkitty.models import Rating, Tag
from hyperkitty.lib.mockup import *
+from hyperkitty.lib import ThreadSafeStorePool
from forms import *
from hyperkitty.utils import log
-import kittystore
-STORE = kittystore.get_store(settings.KITTYSTORE_URL)
-
# @TODO : Move this into settings.py
MONTH_PARTICIPANTS = 284
@@ -70,17 +68,18 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None):
search_form = SearchForm(auto_id=False)
t = loader.get_template('month_view.html')
- threads = STORE.get_archives(list_name, start=begin_date,
+ STORE = ThreadSafeStorePool().get()
+ threads = STORE.get_archives(mlist_fqdn, start=begin_date,
end=end_date)
participants = set()
cnt = 0
for thread in threads:
# Statistics on how many participants and threads this month
- participants.add(thread.sender)
- thread.participants = STORE.get_thread_participants(list_name,
+ participants.add(thread.sender_name)
+ thread.participants = STORE.get_thread_participants(mlist_fqdn,
thread.thread_id)
- thread.answers = STORE.get_thread_length(list_name,
+ thread.answers = STORE.get_thread_length(mlist_fqdn,
thread.thread_id)
highestlike = 0
@@ -89,7 +88,7 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None):
totalvotes = 0
totallikes = 0
totaldislikes = 0
- messages = STORE.get_thread(list_name, thread.thread_id)
+ messages = STORE.get_thread(mlist_fqdn, thread.thread_id)
for message in messages:
# Extract all the votes for this message
@@ -139,7 +138,7 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None):
threads = paginator.page(paginator.num_pages)
- archives_length = STORE.get_archives_length(list_name)
+ archives_length = STORE.get_archives_length(mlist_fqdn)
c = RequestContext(request, {
'list_name' : list_name,
@@ -174,7 +173,8 @@ def list(request, mlist_fqdn=None):
end_date = datetime(today.year, today.month, today.day)
begin_date = end_date - timedelta(days=32)
- threads = STORE.get_archives(list_name=list_name, start=begin_date,
+ STORE = ThreadSafeStorePool().get()
+ threads = STORE.get_archives(list_name=mlist_fqdn, start=begin_date,
end=end_date)
participants = set()
@@ -193,10 +193,10 @@ def list(request, mlist_fqdn=None):
else:
dates[key] = 1
# Statistics on how many participants and threads this month
- participants.add(msg.sender)
- msg.participants = STORE.get_thread_participants(list_name,
+ participants.add(msg.sender_name)
+ msg.participants = STORE.get_thread_participants(mlist_fqdn,
msg.thread_id)
- msg.answers = STORE.get_thread_length(list_name,
+ msg.answers = STORE.get_thread_length(mlist_fqdn,
msg.thread_id)
threads[cnt] = msg
cnt = cnt + 1
@@ -207,7 +207,7 @@ def list(request, mlist_fqdn=None):
# active threads are the ones that have the most recent posting
active_threads = sorted(threads, key=lambda entry: entry.date, reverse=True)
- archives_length = STORE.get_archives_length(list_name)
+ archives_length = STORE.get_archives_length(mlist_fqdn)
# top authors are the ones that have the most kudos. How do we determine
# that? Most likes for their post?
@@ -254,7 +254,7 @@ def _search_results_page(request, mlist_fqdn, threads, search_type,
participants = set()
for msg in threads:
- participants.add(msg.sender)
+ participants.add(msg.sender_name)
paginator = Paginator(threads, num_threads)
@@ -264,15 +264,16 @@ def _search_results_page(request, mlist_fqdn, threads, search_type,
except (EmptyPage, InvalidPage):
threads = paginator.page(paginator.num_pages)
+ STORE = ThreadSafeStorePool().get()
cnt = 0
for msg in threads.object_list:
- msg.email = msg.email.strip()
+ msg.email = msg.sender_email.strip()
# Statistics on how many participants and threads this month
- participants.add(msg.sender)
+ participants.add(msg.sender_name)
if msg.thread_id:
- msg.participants = STORE.get_thread_participants(list_name,
+ msg.participants = STORE.get_thread_participants(mlist_fqdn,
msg.thread_id)
- msg.answers = STORE.get_thread_length(list_name,
+ msg.answers = STORE.get_thread_length(mlist_fqdn,
msg.thread_id)
else:
msg.participants = 0
@@ -309,6 +310,7 @@ def search(request, mlist_fqdn):
def search_keyword(request, mlist_fqdn, target, keyword, page=1):
## Should we remove the code below?
## If urls.py does it job we should never need it
+ STORE = ThreadSafeStorePool().get()
if not keyword:
keyword = request.GET.get('keyword')
if not target:
@@ -318,13 +320,13 @@ def search_keyword(request, mlist_fqdn, target, keyword, page=1):
regex = '%%%s%%' % keyword
list_name = mlist_fqdn.split('@')[0]
if target.lower() == 'subjectcontent':
- threads = STORE.search_content_subject(list_name, keyword)
+ threads = STORE.search_content_subject(mlist_fqdn, keyword)
elif target.lower() == 'subject':
- threads = STORE.search_subject(list_name, keyword)
+ threads = STORE.search_subject(mlist_fqdn, keyword)
elif target.lower() == 'content':
- threads = STORE.search_content(list_name, keyword)
+ threads = STORE.search_content(mlist_fqdn, keyword)
elif target.lower() == 'from':
- threads = STORE.search_sender(list_name, keyword)
+ threads = STORE.search_sender(mlist_fqdn, keyword)
return _search_results_page(request, mlist_fqdn, threads, 'Search', page)
@@ -332,6 +334,7 @@ def search_keyword(request, mlist_fqdn, target, keyword, page=1):
def search_tag(request, mlist_fqdn, tag=None, page=1):
'''Returns emails having a particular tag'''
+ STORE = ThreadSafeStorePool().get()
list_name = mlist_fqdn.split('@')[0]
try:
@@ -341,7 +344,7 @@ def search_tag(request, mlist_fqdn, tag=None, page=1):
threads = []
for thread in thread_ids:
- threads_tmp = STORE.get_thread(list_name, thread.threadid)
+ threads_tmp = STORE.get_thread(mlist_fqdn, thread.threadid)
threads.append(threads_tmp[0])
return _search_results_page(request, mlist_fqdn, threads,