Add non active users to context menu.
authorMarcin Koziej <marcin@lolownia.org>
Thu, 10 May 2012 13:52:18 +0000 (15:52 +0200)
committerMarcin Koziej <marcin@lolownia.org>
Thu, 10 May 2012 13:52:18 +0000 (15:52 +0200)
apps/catalogue/templates/catalogue/book_list/book_list.html
apps/catalogue/templatetags/book_list.py
redakcja/static/js/catalogue/book_list.js

index f1ed46f..8b76326 100755 (executable)
 <input type="hidden" name="status" />
 </form>
 
+<select name="other-user" style="display:none;">
+  {% for user in other_users %}
+  <option {% if request.GET.user == user.username %}selected="selected"
+          {% endif %}value="{{ user.username }}">{{ user.first_name }} {{ user.last_name }} ({{ user.count }})</option>
+  {% endfor %}
+</select>
+
index f7e7047..46cf87a 100755 (executable)
@@ -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,
index 4d67ca1..a3d092b 100644 (file)
                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());
                },
                "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": {