diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-06-12 20:55:20 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-06-12 20:55:20 +0200 |
commit | 8a8b9f5a0b174225230c2ddb2dc9a0cecb33208e (patch) | |
tree | c1ba1ed6f42be001dd19758b6fd2f10510538ad8 /hyperkitty/views/accounts.py | |
parent | a195f1b150d2b17cdefd64038528b53035d585f7 (diff) | |
download | hyperkitty-8a8b9f5a0b174225230c2ddb2dc9a0cecb33208e.tar.gz hyperkitty-8a8b9f5a0b174225230c2ddb2dc9a0cecb33208e.tar.xz hyperkitty-8a8b9f5a0b174225230c2ddb2dc9a0cecb33208e.zip |
Paginate the list of liked messages in the user profile
Diffstat (limited to 'hyperkitty/views/accounts.py')
-rw-r--r-- | hyperkitty/views/accounts.py | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/hyperkitty/views/accounts.py b/hyperkitty/views/accounts.py index d7e35c2..9e1c4aa 100644 --- a/hyperkitty/views/accounts.py +++ b/hyperkitty/views/accounts.py @@ -87,25 +87,6 @@ def user_profile(request, user_email=None): "timezone": get_current_timezone(), }) - # Votes - try: - votes = Rating.objects.filter(user=request.user) - except Rating.DoesNotExist: - votes = [] - votes_up = [] - votes_down = [] - for vote in votes: - message = store.get_message_by_hash_from_list( - vote.list_address, vote.messageid) - vote_data = {"list_address": vote.list_address, - "messageid": vote.messageid, - "message": message, - } - if vote.vote == 1: - votes_up.append(vote_data) - elif vote.vote == -1: - votes_down.append(vote_data) - # Favorites try: favorites = Favorite.objects.filter(user=request.user) @@ -126,8 +107,6 @@ def user_profile(request, user_email=None): context = { 'user_profile' : user_profile, 'form': form, - 'votes_up': votes_up, - 'votes_down': votes_down, 'favorites': favorites, 'flash_messages': flash_messages, } @@ -195,3 +174,20 @@ def last_views(request): return render(request, 'ajax/last_views.html', { "last_views": last_views, }) + + +@login_required +def votes(request): + store = get_store(request) + # Votes + try: + votes = Rating.objects.filter(user=request.user) + except Rating.DoesNotExist: + votes = [] + votes = paginate(votes, request.GET.get('vpage')) + for vote in votes: + vote.message = store.get_message_by_hash_from_list( + vote.list_address, vote.messageid) + return render(request, 'ajax/votes.html', { + "votes": votes, + }) |