From ea032ba8b321fad5e896750eae508456676041c1 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Thu, 23 May 2013 15:45:22 +0200 Subject: Display the last viewed threads in the user profile --- hyperkitty/static/css/hyperkitty-user.css | 7 ++++++ hyperkitty/static/js/hyperkitty.js | 29 ++++++++++++++++++++++ hyperkitty/templates/ajax/last_views.html | 40 +++++++++++++++++++++++++++++++ hyperkitty/templates/paginator.html | 4 ++-- hyperkitty/templates/user_profile.html | 16 +++++++++++++ hyperkitty/templatetags/hk_generic.py | 2 +- hyperkitty/urls.py | 1 + hyperkitty/views/accounts.py | 32 ++++++++++++++++++++++++- 8 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 hyperkitty/templates/ajax/last_views.html diff --git a/hyperkitty/static/css/hyperkitty-user.css b/hyperkitty/static/css/hyperkitty-user.css index 49edfa6..77d9ad4 100644 --- a/hyperkitty/static/css/hyperkitty-user.css +++ b/hyperkitty/static/css/hyperkitty-user.css @@ -84,3 +84,10 @@ table.user-data label, table.user-data input { margin-bottom: 0; } + + +.ajaxloader { + margin-top: 0; + margin-left: 0; + position: absolute; +} diff --git a/hyperkitty/static/js/hyperkitty.js b/hyperkitty/static/js/hyperkitty.js index fc8e461..5fcb539 100644 --- a/hyperkitty/static/js/hyperkitty.js +++ b/hyperkitty/static/js/hyperkitty.js @@ -419,6 +419,35 @@ function update_list_properties(url) { } +/* + * Last viewed threads in the user's profile + */ +function update_last_views(base_url) { + var container = $(".views"); + var loader = container.prev(".ajaxloader"); + function _update(url) { + loader.show(); + $.ajax({ + url: url, + success: function(data) { + container.html(data); + container.find(".pager a").click(function(e) { + e.preventDefault(); + _update(base_url + $(this).attr("href")); + }); + }, + error: function(jqXHR, textStatus, errorThrown) { + //alert(jqXHR.responseText); + }, + complete: function(jqXHR, textStatus) { + loader.hide(); + } + }); + } + _update(base_url); +} + + /* * Misc. */ diff --git a/hyperkitty/templates/ajax/last_views.html b/hyperkitty/templates/ajax/last_views.html new file mode 100644 index 0000000..5455413 --- /dev/null +++ b/hyperkitty/templates/ajax/last_views.html @@ -0,0 +1,40 @@ +{% load url from future %} +{% load i18n %} +{% load hk_generic %} + + {% if last_views %} + + + + + + + + + + + + + {% for lv in last_views %} + + + + + + + + + {% endfor %} + +
SubjectOriginal authorStart dateLast activityReplies
+ {% if thread.unread %} + + {% endif %} + {{ lv.thread.starting_email.subject }}{{ lv.thread.starting_email.sender_name }}{{ lv.thread.starting_email|viewer_date|date:"l, j F Y H:i:s" }}{{ lv.thread|viewer_date|timesince }}{{ lv.thread|length }}
+ {% include "paginator.html" with pager=last_views page_key="lvpage" %} + {% else %} +

Nothing read yet.

+ {% endif %} + +{# vim: set noet: #} diff --git a/hyperkitty/templates/paginator.html b/hyperkitty/templates/paginator.html index a7559ec..358ae5d 100644 --- a/hyperkitty/templates/paginator.html +++ b/hyperkitty/templates/paginator.html @@ -2,7 +2,7 @@