On the frontend, only show hosts to which this user has ACL access.
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1343 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 389a58d..46a0f36 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -29,6 +29,7 @@
__author__ = 'showard@google.com (Steve Howard)'
+import itertools
import models, control_file, rpc_utils
# labels
@@ -87,6 +88,19 @@
return rpc_utils.prepare_for_serialization(hosts)
+def get_hosts_acld_to(user, **filter_data):
+ """\
+ Like get_hosts(), but only return hosts to which the given user has
+ ACL access.
+ """
+ user = models.User.smart_get(user)
+ # get hosts for each ACL group to which this user belongs
+ host_groups = [get_hosts(acl_group=acl_group, **filter_data)
+ for acl_group in user.aclgroup_set.all()]
+ # consolidate into unique hosts
+ hosts = rpc_utils.gather_unique_dicts(itertools.chain(*host_groups))
+ return hosts
+
# tests
@@ -347,7 +361,7 @@
users: sorted list of all usernames
labels: sorted list of all label names
tests: sorted list of all test names
- user_login: username
+ user_login: logged-in username
"""
result = {}
result['priorities'] = models.Job.Priority.choices()