diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-07-11 20:15:07 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-07-11 20:15:07 +0200 |
commit | ce57f4cbe44d2594ff11aba8501a1d8f2727fd70 (patch) | |
tree | 6e81f66caa5dc77644ba6c1b6f5d1c882e33be50 | |
parent | a3a4ce32f0596ff0bf48c7cc04292389e0d9627d (diff) | |
download | hyperkitty-ce57f4cbe44d2594ff11aba8501a1d8f2727fd70.tar.gz hyperkitty-ce57f4cbe44d2594ff11aba8501a1d8f2727fd70.tar.xz hyperkitty-ce57f4cbe44d2594ff11aba8501a1d8f2727fd70.zip |
Handle leftover votes & favorites
-rw-r--r-- | hyperkitty/templatetags/hk_generic.py | 2 | ||||
-rw-r--r-- | hyperkitty/views/accounts.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/hyperkitty/templatetags/hk_generic.py b/hyperkitty/templatetags/hk_generic.py index 25b240c..4e31a09 100644 --- a/hyperkitty/templatetags/hk_generic.py +++ b/hyperkitty/templatetags/hk_generic.py @@ -137,6 +137,8 @@ def get_date(email_or_thread): date_obj = email_or_thread.date.replace(tzinfo=tz) elif hasattr(email_or_thread, 'date_active'): date_obj = email_or_thread.date_active.replace(tzinfo=utc) + else: + raise ValueError(email_or_thread) return date_obj diff --git a/hyperkitty/views/accounts.py b/hyperkitty/views/accounts.py index b88919e..3a91c3d 100644 --- a/hyperkitty/views/accounts.py +++ b/hyperkitty/views/accounts.py @@ -95,6 +95,9 @@ def user_profile(request, user_email=None): for fav in favorites: thread = store.get_thread(fav.list_address, fav.threadid) fav.thread = thread + if thread is None: + fav.delete() # thread has gone away? + favorites = [ f for f in favorites if f.thread is not None ] # Flash messages flash_messages = [] @@ -164,13 +167,17 @@ def last_views(request): last_views = paginate(last_views, request.GET.get('lvpage')) for last_view in last_views: thread = store.get_thread(last_view.list_address, last_view.threadid) + last_view.thread = thread + if thread is None: + last_view.delete() + continue if thread.date_active.replace(tzinfo=utc) > last_view.view_date: # small optimization: only query the replies if necessary # XXX: Storm-specific (count method) thread.unread = thread.replies_after(last_view.view_date).count() else: thread.unread = 0 - last_view.thread = thread + last_views = [ lv for lv in last_views if lv.thread is not None ] return render(request, 'ajax/last_views.html', { "last_views": last_views, @@ -189,6 +196,9 @@ def votes(request): for vote in votes: vote.message = store.get_message_by_hash_from_list( vote.list_address, vote.messageid) + if vote.message is None: + vote.delete() + votes = [ v for v in votes if v.message is not None ] return render(request, 'ajax/votes.html', { "votes": votes, }) |