blob: 710011a3cb2f19e85aec92dc28ce36ecab37106c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#-*- coding: utf-8 -*-
import urllib
from hashlib import md5
import datetime
from django.conf import settings
import kittystore
from hyperkitty.utils import log
def gravatar_url(email):
'''Return a gravatar url for an email address'''
size = 64
default = "http://fedoraproject.org/static/images/" + \
"fedora_infinity_%ix%i.png" % (size, size)
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
def get_store(request):
return request.environ["kittystore.store"]
|