diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-08-15 11:11:02 +0000 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-08-15 11:11:22 +0000 |
commit | a77a567329baf8156a782c2dde8e80f38740a97a (patch) | |
tree | e8c149b96ba65236f91e03654b448d52013e0b7a | |
parent | 4c1c013620909a0f3490d1a6582924a567dea455 (diff) | |
download | hyperkitty-a77a567329baf8156a782c2dde8e80f38740a97a.tar.gz hyperkitty-a77a567329baf8156a782c2dde8e80f38740a97a.tar.xz hyperkitty-a77a567329baf8156a782c2dde8e80f38740a97a.zip |
Load subscriptions asynchronously
-rw-r--r-- | hyperkitty/static/hyperkitty/css/hyperkitty-base.css | 7 | ||||
-rw-r--r-- | hyperkitty/static/hyperkitty/js/hyperkitty-userprofile.js | 5 | ||||
-rw-r--r-- | hyperkitty/templates/base.html | 3 | ||||
-rw-r--r-- | hyperkitty/templates/user_profile.html | 12 | ||||
-rw-r--r-- | hyperkitty/urls.py | 1 | ||||
-rw-r--r-- | hyperkitty/views/accounts.py | 23 |
6 files changed, 39 insertions, 12 deletions
diff --git a/hyperkitty/static/hyperkitty/css/hyperkitty-base.css b/hyperkitty/static/hyperkitty/css/hyperkitty-base.css index 85f6cc9..418d323 100644 --- a/hyperkitty/static/hyperkitty/css/hyperkitty-base.css +++ b/hyperkitty/static/hyperkitty/css/hyperkitty-base.css @@ -38,3 +38,10 @@ ul.nav.auth { .navbar .breadcrumb > li > .divider { color: #999999; } + + +/* Sometimes jQuery UI overwrites the Bootstrap values */ + +a, .ui-widget-content a { + color: #0088cc; +} diff --git a/hyperkitty/static/hyperkitty/js/hyperkitty-userprofile.js b/hyperkitty/static/hyperkitty/js/hyperkitty-userprofile.js index d755f6f..9658bb3 100644 --- a/hyperkitty/static/hyperkitty/js/hyperkitty-userprofile.js +++ b/hyperkitty/static/hyperkitty/js/hyperkitty-userprofile.js @@ -23,9 +23,10 @@ /* * Last viewed threads and votes in the user's profile */ -function update_user_profile_part(container, base_url) { +function update_user_profile_part(container) { container = $(container); - var loader = container.prev(".ajaxloader"); + base_url = container.attr("data-load-from"); + var loader = container.parent().find(".ajaxloader"); function _update(url) { loader.show(); $.ajax({ diff --git a/hyperkitty/templates/base.html b/hyperkitty/templates/base.html index 393bb80..e7d5303 100644 --- a/hyperkitty/templates/base.html +++ b/hyperkitty/templates/base.html @@ -10,7 +10,8 @@ <meta name="dc.language" content="en" /> <link rel="shortcut icon" href="{{ STATIC_URL }}hyperkitty/img/favicon.ico" /> <link rel="stylesheet" media="all" href="{{ STATIC_URL }}hyperkitty/libs/jquery/smoothness/jquery-ui-1.10.3.custom.min.css" /> - {% assets filters="cssrewrite,cssmin", output="gen/hyperkitty.css", "hyperkitty/libs/bootstrap/css/bootstrap.min.css", "hyperkitty/css/hyperkitty-base.css", "hyperkitty/css/hyperkitty-common.css", "hyperkitty/css/hyperkitty-index.css", "hyperkitty/css/hyperkitty-user.css", "hyperkitty/css/hyperkitty-overview.css", "hyperkitty/css/hyperkitty-threadslist.css", "hyperkitty/css/hyperkitty-message.css" %} + <link rel="stylesheet" media="all" href="{{ STATIC_URL }}hyperkitty/libs/bootstrap/css/bootstrap.min.css" /> + {% assets filters="cssrewrite,cssmin", output="gen/hyperkitty.css", "hyperkitty/css/hyperkitty-base.css", "hyperkitty/css/hyperkitty-common.css", "hyperkitty/css/hyperkitty-index.css", "hyperkitty/css/hyperkitty-user.css", "hyperkitty/css/hyperkitty-overview.css", "hyperkitty/css/hyperkitty-threadslist.css", "hyperkitty/css/hyperkitty-message.css" %} <link rel="stylesheet" media="all" href="{{ ASSET_URL }}" /> {% endassets %} {% block additional_stylesheets %} {% endblock %} diff --git a/hyperkitty/templates/user_profile.html b/hyperkitty/templates/user_profile.html index 1d25499..e6cb8bd 100644 --- a/hyperkitty/templates/user_profile.html +++ b/hyperkitty/templates/user_profile.html @@ -93,18 +93,19 @@ <div id="views"> <img alt="Loading..." class="ajaxloader" src="{{ STATIC_URL }}hyperkitty/img/ajax-loader.gif" /> - <div class="ajaxcontent"></div> + <div class="ajaxcontent" data-load-from="{% url 'user_last_views' %}"></div> </div> <div id="votes"> <img alt="Loading..." class="ajaxloader" src="{{ STATIC_URL }}hyperkitty/img/ajax-loader.gif" /> - <div class="ajaxcontent"></div> + <div class="ajaxcontent" data-load-from="{% url 'user_votes' %}"></div> </div> <div id="subscriptions"> - {% include "fragments/user_subscriptions.html" %} + <img alt="Loading..." class="ajaxloader" src="{{ STATIC_URL }}hyperkitty/img/ajax-loader.gif" /> + <div class="ajaxcontent" data-load-from="{% url 'user_subscriptions' %}"></div> </div> </div> @@ -118,8 +119,9 @@ $(document).ready(function() { // Load the last views $(".tabbed").tabs(); - update_user_profile_part("#views div.ajaxcontent", "{% url 'user_last_views' %}"); - update_user_profile_part("#votes div.ajaxcontent", "{% url 'user_votes' %}"); + $("div.ajaxcontent").each(function() { + update_user_profile_part($(this)); + }); }); </script> diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py index c24615a..8a6c161 100644 --- a/hyperkitty/urls.py +++ b/hyperkitty/urls.py @@ -48,6 +48,7 @@ urlpatterns = patterns('hyperkitty.views', url(r'^accounts/profile/$', 'accounts.user_profile', name='user_profile'), url(r'^accounts/profile/last_views$', 'accounts.last_views', name='user_last_views'), url(r'^accounts/profile/votes$', 'accounts.votes', name='user_votes'), + url(r'^accounts/profile/subscriptions$', 'accounts.subscriptions', name='user_subscriptions'), url(r'^accounts/register/$', 'accounts.user_registration', {'SSL': True}, name='user_registration'), # Users diff --git a/hyperkitty/views/accounts.py b/hyperkitty/views/accounts.py index b4c8759..9a6b9ff 100644 --- a/hyperkitty/views/accounts.py +++ b/hyperkitty/views/accounts.py @@ -128,9 +128,6 @@ def user_profile(request): if addr != request.user.email: emails.append(addr) - # Subscriptions - subscriptions = get_subscriptions(store, mm_client, mm_user) - # Flash messages flash_messages = [] flash_msg = request.GET.get("msg") @@ -144,7 +141,6 @@ def user_profile(request): 'form': form, 'emails': emails, 'favorites': favorites, - 'subscriptions': subscriptions, 'flash_messages': flash_messages, } return render(request, "user_profile.html", context) @@ -238,6 +234,25 @@ def votes(request): }) +@login_required +def subscriptions(request): + store = get_store(request) + # get the Mailman user + try: + mm_client = mailmanclient.Client('%s/3.0' % + settings.MAILMAN_REST_SERVER, + settings.MAILMAN_API_USER, + settings.MAILMAN_API_PASS) + mm_user = mm_client.get_user(request.user.email) + except (HTTPError, mailmanclient.MailmanConnectionError): + mm_client = mm_user = None + # Subscriptions + subscriptions = get_subscriptions(store, mm_client, mm_user) + return render(request, 'fragments/user_subscriptions.html', { + "subscriptions": subscriptions, + }) + + def public_profile(request, user_id): try: client = mailmanclient.Client('%s/3.0' % |