From 511858804af15c63bb6bc1e1f27cfbb6da77040d Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 30 Sep 2014 14:26:14 +0200 Subject: [PATCH] add Find: Group to Manage Users, #1878 --- pandora/user/managers.py | 2 ++ pandora/user/views.py | 2 +- static/js/usersDialog.js | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pandora/user/managers.py b/pandora/user/managers.py index 5db9b4979..f09238b64 100644 --- a/pandora/user/managers.py +++ b/pandora/user/managers.py @@ -9,6 +9,8 @@ def parseCondition(condition, user): k = { 'email': 'user__email', 'user': 'username', + 'group': 'user__groups__name', + 'groups': 'user__groups__name', }.get(k, k) v = condition['value'] op = condition.get('operator') diff --git a/pandora/user/views.py b/pandora/user/views.py index 6516318d4..1286c6b37 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -477,7 +477,7 @@ def findUsers(request): } possible query keys: - username, email, lastLogin, browser + username, email, lastLogin, browser, groups returns { items: [ diff --git a/static/js/usersDialog.js b/static/js/usersDialog.js index 179bf4fdc..c4bccdf75 100644 --- a/static/js/usersDialog.js +++ b/static/js/usersDialog.js @@ -65,7 +65,8 @@ pandora.ui.usersDialog = function() { items: [ {id: 'all', title: Ox._('Find: All')}, {id: 'username', title: Ox._('Find: Username')}, - {id: 'email', title: Ox._('Find: E-Mail Address')} + {id: 'email', title: Ox._('Find: E-Mail Address')}, + {id: 'group', title: Ox._('Find: Group')} ], overlap: 'right', type: 'image' @@ -964,8 +965,9 @@ pandora.ui.usersDialog = function() { query = { conditions: value ? [].concat( - key != 'email' ? [{key: 'username', value: value, operator: '='}] : [], - key != 'username' ? [{key: 'email', value: value, operator: '='}] : [] + Ox.contains(['username', 'all'], key) ? [{key: 'username', value: value, operator: '='}] : [], + Ox.contains(['email', 'all'], key) ? [{key: 'email', value: value, operator: '='}] : [], + Ox.contains(['group', 'all'], key) ? [{key: 'group', value: value, operator: '='}] : [] ) : [].concat( !guests ? [{key: 'level', value: 'guest', operator: '!='}] : [],