summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-07-18 13:49:50 +0200
committerAurélien Bompard <aurelien@bompard.org>2013-07-18 13:49:50 +0200
commit3b96d9f431cff58dbcf6dad403a3edb298d48713 (patch)
tree0a21e8ebcc0be7aa47c9725a1987753ad5084f15
parentd7fed57eb29d33909e1acc96f6e4cf41ea601378 (diff)
downloadkittystore-3b96d9f431cff58dbcf6dad403a3edb298d48713.tar.gz
kittystore-3b96d9f431cff58dbcf6dad403a3edb298d48713.tar.xz
kittystore-3b96d9f431cff58dbcf6dad403a3edb298d48713.zip
Add methods to attach an email to a thread and to delete a thread
-rw-r--r--kittystore/storm/model.py1
-rw-r--r--kittystore/storm/store.py24
2 files changed, 25 insertions, 0 deletions
diff --git a/kittystore/storm/model.py b/kittystore/storm/model.py
index 329488c..90cbe18 100644
--- a/kittystore/storm/model.py
+++ b/kittystore/storm/model.py
@@ -232,6 +232,7 @@ class Thread(Storm):
if category is None:
category = Category(name)
store.add(category)
+ store.flush()
self.category_id = category.id
category = property(_get_category, _set_category)
diff --git a/kittystore/storm/store.py b/kittystore/storm/store.py
index 542fd5e..99d303b 100644
--- a/kittystore/storm/store.py
+++ b/kittystore/storm/store.py
@@ -165,6 +165,18 @@ class StormStore(object):
self.search_index.add(email)
return email.message_id_hash
+ def attach_to_thread(self, email, thread):
+ """Attach an email to an existing thread"""
+ if email.date <= thread.starting_email.date:
+ raise ValueError("Can't attach emails older than the first "
+ "email in a thread")
+ email.thread_id = thread.thread_id
+ email.in_reply_to = thread.starting_email.message_id
+ if email.date > thread.date_active:
+ thread.date_active = email.date
+ compute_thread_order_and_depth(thread)
+ self.flush()
+
def delete_message(self, message_id):
"""Remove the given message from the store.
@@ -467,6 +479,18 @@ class StormStore(object):
prev_thread = None
return (prev_thread, next_thread)
+ def delete_thread(self, list_name, thread_id):
+ """ Delete the specified thread.
+
+ :param list_name: The name of the mailing list containing this thread
+ :param thread_id: The thread_id as used in the web-pages. Used here to
+ uniquely identify the thread in the database.
+ """
+ self.db.find(Thread, And(
+ Thread.list_name == unicode(list_name),
+ Thread.thread_id == unicode(thread_id)
+ )).remove()
+
def get_list(self, list_name):
""" Return the list object for a mailing list name.