summaryrefslogtreecommitdiffstats
path: root/hyperkitty
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-01-09 15:19:30 +0100
committerAurélien Bompard <aurelien@bompard.org>2013-01-09 15:19:30 +0100
commite45d9e5ac7b3329cc028fa256daa15c485c8f09e (patch)
tree972f04e0dd7ba76c40a043363f2bd84d02ba7f89 /hyperkitty
parent18dca8fc476ec8724adb15ecd7aa9fe02813b416 (diff)
downloadhyperkitty-e45d9e5ac7b3329cc028fa256daa15c485c8f09e.tar.gz
hyperkitty-e45d9e5ac7b3329cc028fa256daa15c485c8f09e.tar.xz
hyperkitty-e45d9e5ac7b3329cc028fa256daa15c485c8f09e.zip
Move the thread sorting code to kittystore
Diffstat (limited to 'hyperkitty')
-rw-r--r--hyperkitty/lib/__init__.py21
-rw-r--r--hyperkitty/views/thread.py6
2 files changed, 3 insertions, 24 deletions
diff --git a/hyperkitty/lib/__init__.py b/hyperkitty/lib/__init__.py
index 14bde15..52b6bdc 100644
--- a/hyperkitty/lib/__init__.py
+++ b/hyperkitty/lib/__init__.py
@@ -23,7 +23,6 @@ import urllib
from hashlib import md5
import datetime
-import networkx as nx
from django.conf import settings
@@ -87,23 +86,3 @@ def get_display_dates(year, month, day):
end_date = begin_date + datetime.timedelta(days=1)
return begin_date, end_date
-
-
-def sort_thread(thread):
- def walk_successors(msgid, level, result):
- obj = graph.node[msgid]["obj"]
- obj.level = level
- result.append(obj)
- level += 1
- for succ in sorted(graph.successors(msgid),
- key=lambda m: graph.node[m]["num"]):
- walk_successors(succ, level, result)
- level -= 1
- graph = nx.DiGraph()
- for index, email in enumerate(thread.emails):
- graph.add_node(email.message_id, num=index, obj=email)
- if email.in_reply_to is not None:
- graph.add_edge(email.in_reply_to, email.message_id)
- result = []
- walk_successors(thread.starting_email.message_id, 0, result)
- return result
diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py
index f0c959f..fc78cbe 100644
--- a/hyperkitty/views/thread.py
+++ b/hyperkitty/views/thread.py
@@ -37,7 +37,7 @@ from django.contrib.auth.decorators import (login_required,
from hyperkitty.models import Rating, Tag
#from hyperkitty.lib.mockup import *
from forms import *
-from hyperkitty.lib import get_months, get_store, stripped_subject, sort_thread
+from hyperkitty.lib import get_months, get_store, stripped_subject
def thread_index(request, mlist_fqdn, threadid):
@@ -55,7 +55,7 @@ def thread_index(request, mlist_fqdn, threadid):
emails = thread.emails
else:
sort_mode = "thread"
- emails = sort_thread(thread)
+ emails = thread.emails_by_reply
participants = {}
for email in emails:
@@ -92,7 +92,7 @@ def thread_index(request, mlist_fqdn, threadid):
participants[email.sender_name] = email.sender_email
if sort_mode == "thread":
- email.level -= 1 # replies start ragged left
+ email.level = email.thread_depth - 1 # replies start ragged left
if email.level > 5:
email.level = 5