summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-07-04 09:56:16 +0200
committerAurélien Bompard <aurelien@bompard.org>2013-07-08 11:06:18 +0200
commit8301b45160da213d1f52fddc3527b81959dd3a08 (patch)
tree85b571ed75449eb51a8abdfff562ab4befb0369d
parentbf11c8868b64774c9ad207a9cefe5ee99159c29d (diff)
downloadhyperkitty-8301b45160da213d1f52fddc3527b81959dd3a08.tar.gz
hyperkitty-8301b45160da213d1f52fddc3527b81959dd3a08.tar.xz
hyperkitty-8301b45160da213d1f52fddc3527b81959dd3a08.zip
Request list info on the front page in bulk
-rw-r--r--hyperkitty/static/js/hyperkitty-frontpage.js21
-rw-r--r--hyperkitty/views/pages.py3
2 files changed, 21 insertions, 3 deletions
diff --git a/hyperkitty/static/js/hyperkitty-frontpage.js b/hyperkitty/static/js/hyperkitty-frontpage.js
index fbcb12d..c38ed2f 100644
--- a/hyperkitty/static/js/hyperkitty-frontpage.js
+++ b/hyperkitty/static/js/hyperkitty-frontpage.js
@@ -24,11 +24,21 @@
* List descriptions on the front page
*/
function update_list_properties(url) {
+ // Don't try to update them all at once, there may be hundreds of lists
+ var bulksize = 5;
+ // If there is still an ajaxloader, then request the properties
+ var lists = $(".all-lists .mailinglist img.ajaxloader")
+ .slice(0, bulksize).parents(".mailinglist");
+ if (lists.length === 0) {
+ return;
+ }
+ var listnames = $.makeArray(lists.find(".list-address").map(
+ function() { return $(this).text(); }));
$.ajax({
dataType: "json",
- url: url,
+ url: url + "?name=" + listnames.join("&name="),
success: function(data) {
- $(".all-lists .mailinglist").each(function() {
+ lists.each(function() {
var name = $(this).find(".list-address").text();
if (!data[name]) {
return;
@@ -46,7 +56,12 @@ function update_list_properties(url) {
//alert(jqXHR.responseText);
},
complete: function(jqXHR, textStatus) {
- $(".all-lists .mailinglist img.ajaxloader").remove();
+ // Request may have failed if mailman's REST server is unavailable,
+ // keep going anyway.
+ lists.find("img.ajaxloader").remove();
+ // do it again, until all lists have been populated (or at least we
+ // tried to)
+ update_list_properties(url);
}
});
}
diff --git a/hyperkitty/views/pages.py b/hyperkitty/views/pages.py
index fa529c0..c6f3582 100644
--- a/hyperkitty/views/pages.py
+++ b/hyperkitty/views/pages.py
@@ -47,6 +47,9 @@ def list_properties(request):
"""Get JSON encoded list properties"""
store = get_store(request)
lists = store.get_lists()
+ onlynames = request.GET.getlist("name")
+ if onlynames:
+ lists = [ l for l in lists if l.name in onlynames ]
client = Client('%s/3.0' % settings.MAILMAN_REST_SERVER,
settings.MAILMAN_API_USER, settings.MAILMAN_API_PASS)
props = {}