summaryrefslogtreecommitdiffstats
path: root/hyperkitty/lib
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2012-09-05 14:43:39 +0200
committerAurélien Bompard <aurelien@bompard.org>2012-09-05 14:43:39 +0200
commit54f6eb7982a562a3526ee3b9be62fa6e9344dbdb (patch)
tree1bc46849e095bd5868e13ca78a6479c4c4164b29 /hyperkitty/lib
parentf409640d25c33247d06a3f00c006426e593cb751 (diff)
downloadhyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.tar.gz
hyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.tar.xz
hyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.zip
Adapt to KittyStore's API change
Diffstat (limited to 'hyperkitty/lib')
-rw-r--r--hyperkitty/lib/__init__.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/hyperkitty/lib/__init__.py b/hyperkitty/lib/__init__.py
index 887cfd5..9b541f9 100644
--- a/hyperkitty/lib/__init__.py
+++ b/hyperkitty/lib/__init__.py
@@ -3,6 +3,7 @@
import urllib
from hashlib import md5
import threading
+import datetime
from django.conf import settings
@@ -35,3 +36,27 @@ def gravatar_url(email):
query_string = urllib.urlencode({'s': size, 'd': default})
identifier = md5(email).hexdigest()
return 'http://www.gravatar.com/avatar/%s?%s' % (identifier, query_string)
+
+
+def get_months(store, list_name):
+ """ Return a dictionnary of years, months for which there are
+ potentially archives available for a given list (based on the
+ oldest post on the list).
+
+ :arg list_name, name of the mailing list in which this email
+ should be searched.
+ """
+ date_first = store.get_start_date(list_name)
+ if not date_first:
+ return {}
+ archives = {}
+ now = datetime.datetime.now()
+ year = date_first.year
+ month = date_first.month
+ while year < now.year:
+ archives[year] = range(1, 13)[(month -1):]
+ year = year + 1
+ month = 1
+ archives[now.year] = range(1, 13)[:now.month]
+ return archives
+