From 020556cb431cabc6357bf02d88ab993cfe86f16a Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Thu, 10 May 2012 15:52:18 +0200 Subject: [PATCH] Add non active users to context menu. --- .../templates/catalogue/book_list/book_list.html | 7 +++++++ apps/catalogue/templatetags/book_list.py | 9 +++++++-- redakcja/static/js/catalogue/book_list.js | 15 +++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/apps/catalogue/templates/catalogue/book_list/book_list.html b/apps/catalogue/templates/catalogue/book_list/book_list.html index f1ed46f5..8b763268 100755 --- a/apps/catalogue/templates/catalogue/book_list/book_list.html +++ b/apps/catalogue/templates/catalogue/book_list/book_list.html @@ -90,3 +90,10 @@ + + diff --git a/apps/catalogue/templatetags/book_list.py b/apps/catalogue/templatetags/book_list.py index f7e70474..46cf87a4 100755 --- a/apps/catalogue/templatetags/book_list.py +++ b/apps/catalogue/templatetags/book_list.py @@ -125,9 +125,14 @@ def book_list(context, user=None): new_context = {"viewed_user": user} else: filters = {} - new_context = {"users": User.objects.annotate( + new_context = { + "users": User.objects.annotate( count=Count('chunk')).filter(count__gt=0).order_by( - '-count', 'last_name', 'first_name')} + '-count', 'last_name', 'first_name'), + "other_users": User.objects.annotate( + count=Count('chunk')).filter(count=0).order_by( + 'last_name', 'first_name'), + } new_context.update({ "filters": True, diff --git a/redakcja/static/js/catalogue/book_list.js b/redakcja/static/js/catalogue/book_list.js index 4d67ca12..a3d092bc 100644 --- a/redakcja/static/js/catalogue/book_list.js +++ b/redakcja/static/js/catalogue/book_list.js @@ -31,7 +31,11 @@ var field = kp[0]; var idx = parseInt(kp[1]); - fds[field] = $("select[name="+field+"] option[value!=]").eq(idx).val(); + var target_field = field; + if (field == 'other-user') + target_field = 'user'; + + fds[target_field] = $("select[name="+field+"] option[value!=]").eq(idx).val(); } /* fill in the form */ $("#chunk_mass_edit [name=ids]").val(get_ids()); @@ -70,7 +74,14 @@ }, "user": { name: "Set user", - items: get_items("user"), + items: (function() { + var active_users = get_items("user"); + active_users['other'] = { + name: "Other", + items: get_items("other-user"), + }; + return active_users; + })(), icon: "user", }, "publish": { -- 2.20.1