diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2012-09-05 14:43:39 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2012-09-05 14:43:39 +0200 |
commit | 54f6eb7982a562a3526ee3b9be62fa6e9344dbdb (patch) | |
tree | 1bc46849e095bd5868e13ca78a6479c4c4164b29 | |
parent | f409640d25c33247d06a3f00c006426e593cb751 (diff) | |
download | hyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.tar.gz hyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.tar.xz hyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.zip |
Adapt to KittyStore's API change
-rw-r--r-- | hyperkitty/api.py | 2 | ||||
-rw-r--r-- | hyperkitty/lib/__init__.py | 25 | ||||
-rw-r--r-- | hyperkitty/templates/month_view.html | 4 | ||||
-rw-r--r-- | hyperkitty/templates/threads/right_col.html | 2 | ||||
-rw-r--r-- | hyperkitty/templates/user_profile.html | 2 | ||||
-rw-r--r-- | hyperkitty/views/list.py | 14 | ||||
-rw-r--r-- | hyperkitty/views/thread.py | 6 |
7 files changed, 44 insertions, 11 deletions
diff --git a/hyperkitty/api.py b/hyperkitty/api.py index 1cea89c..1e8a05f 100644 --- a/hyperkitty/api.py +++ b/hyperkitty/api.py @@ -34,7 +34,7 @@ class ThreadResource(View): def get(self, request, mlist_fqdn, threadid): list_name = mlist_fqdn.split('@')[0] STORE = ThreadSafeStorePool().get() - thread = STORE.get_thread(list_name, threadid) + thread = STORE.get_messages_in_thread(list_name, threadid) if not thread: return HttpResponse(status=404) else: 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 + diff --git a/hyperkitty/templates/month_view.html b/hyperkitty/templates/month_view.html index 24e4ae7..91d40f1 100644 --- a/hyperkitty/templates/month_view.html +++ b/hyperkitty/templates/month_view.html @@ -36,6 +36,7 @@ </div> <div class="thread_info"> <ul class="tags inline"> + {% if email.tags|length %} <li> Tags: </li> @@ -44,6 +45,7 @@ <a href="/tag/{{list_address}}/{{tag}}">{{tag}}</a> </li> {% endfor %} + {% endif %} </ul> <ul class="inline-block"> <li class="participant"> @@ -53,11 +55,13 @@ {{email.answers}} comments </li> </ul> + {% if settings.USE_MOCKUPS %} <ul class="inline-block"> <li class="like"> +{{email.avglike}} / - {{email.avgdislike}} </li> </ul> + {% endif %} </div> </div> <!-- End of thread --> diff --git a/hyperkitty/templates/threads/right_col.html b/hyperkitty/templates/threads/right_col.html index 78f0621..19ac788 100644 --- a/hyperkitty/templates/threads/right_col.html +++ b/hyperkitty/templates/threads/right_col.html @@ -21,9 +21,11 @@ old </div> </div> + {% if settings.USE_MOCKUPS %} <p id="add_to_fav"> <a href="#AddFav" class="notsaved">Add to favorite discussions</a> </p> + {% endif %} <!-- End dates --> <hr id="grey"/> <div id="tags"> diff --git a/hyperkitty/templates/user_profile.html b/hyperkitty/templates/user_profile.html index f0aa27e..798a947 100644 --- a/hyperkitty/templates/user_profile.html +++ b/hyperkitty/templates/user_profile.html @@ -33,6 +33,7 @@ </tr> </tbody> </table> + {% if settings.USE_MOCKUPS %} <h3> Up Votes : </h3> <ul> @@ -64,6 +65,7 @@ {% endif %} {% endfor %} </ul> + {% endif %} {% endblock %} diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py index 21a983e..eb3ecd5 100644 --- a/hyperkitty/views/list.py +++ b/hyperkitty/views/list.py @@ -19,7 +19,7 @@ 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 hyperkitty.lib import ThreadSafeStorePool, get_months from forms import * from hyperkitty.utils import log @@ -69,7 +69,7 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): search_form = SearchForm(auto_id=False) t = loader.get_template('month_view.html') STORE = ThreadSafeStorePool().get() - threads = STORE.get_archives(mlist_fqdn, start=begin_date, + threads = STORE.get_threads(mlist_fqdn, start=begin_date, end=end_date) participants = set() @@ -88,7 +88,7 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): totalvotes = 0 totallikes = 0 totaldislikes = 0 - messages = STORE.get_thread(mlist_fqdn, thread.thread_id) + messages = STORE.get_messages_in_thread(mlist_fqdn, thread.thread_id) for message in messages: # Extract all the votes for this message @@ -138,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(mlist_fqdn) + archives_length = get_months(STORE, mlist_fqdn) c = RequestContext(request, { 'list_name' : list_name, @@ -174,7 +174,7 @@ def list(request, mlist_fqdn=None): begin_date = end_date - timedelta(days=32) STORE = ThreadSafeStorePool().get() - threads = STORE.get_archives(list_name=mlist_fqdn, start=begin_date, + threads = STORE.get_threads(list_name=mlist_fqdn, start=begin_date, end=end_date) participants = set() @@ -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(mlist_fqdn) + archives_length = get_months(STORE, mlist_fqdn) # top authors are the ones that have the most kudos. How do we determine # that? Most likes for their post? @@ -351,7 +351,7 @@ def search_tag(request, mlist_fqdn, tag=None, page=1): threads = [] for thread in thread_ids: - threads_tmp = STORE.get_thread(mlist_fqdn, thread.threadid) + threads_tmp = STORE.get_messages_in_thread(mlist_fqdn, thread.threadid) threads.append(threads_tmp[0]) return _search_results_page(request, mlist_fqdn, threads, diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py index 8da41b7..f8820c9 100644 --- a/hyperkitty/views/thread.py +++ b/hyperkitty/views/thread.py @@ -13,7 +13,7 @@ from hyperkitty.models import Rating, Tag from forms import * from hyperkitty.utils import log -from hyperkitty.lib import ThreadSafeStorePool +from hyperkitty.lib import ThreadSafeStorePool, get_months def thread_index (request, mlist_fqdn, threadid): @@ -23,7 +23,7 @@ def thread_index (request, mlist_fqdn, threadid): search_form = SearchForm(auto_id=False) t = loader.get_template('thread.html') STORE = ThreadSafeStorePool().get() - threads = STORE.get_thread(mlist_fqdn, threadid) + threads = STORE.get_messages_in_thread(mlist_fqdn, threadid) #prev_thread = mongo.get_thread_name(list_name, int(threadid) - 1) prev_thread = [] if len(prev_thread) > 30: @@ -65,7 +65,7 @@ def thread_index (request, mlist_fqdn, threadid): participants[message.sender_name] = {'email': message.sender_email} cnt = cnt + 1 - archives_length = STORE.get_archives_length(mlist_fqdn) + archives_length = get_months(STORE, mlist_fqdn) from_url = '/thread/%s/%s/' % (mlist_fqdn, threadid) tag_form = AddTagForm(initial={'from_url' : from_url}) |