miscell
[plcapi.git] / PLC / Methods / GetPersons.py
index a209b87..53143e0 100644 (file)
@@ -44,16 +44,19 @@ class GetPersons(Method):
            'admin' not in self.caller['roles']:
             # Get accounts that we are able to view
             valid_person_ids = [self.caller['person_id']]
-            if 'pi' in self.caller['roles'] and self.caller['site_ids']:
+            if ('pi' in self.caller['roles'] or 'tech' in self.caller['roles']) \
+               and self.caller['site_ids']:
                 sites = Sites(self.api, self.caller['site_ids'])
                 for site in sites:
                     valid_person_ids += site['person_ids']
-
             if not valid_person_ids:
-                return []
+                return[]
 
-            # xxx this looks suspicious
-            # we need to add this restriction even if person_filter is defined
+            # this may look suspicious; what if person_filter is not None ?
+            # turns out the results are getting filtered again below, so we're safe
+            # although this part of the code does not always trigger, it's probably 
+            # a sensible performance enhancement for all the times 
+            # when GetPersons() gets called without an argument
             if person_filter is None:
                 person_filter = valid_person_ids
 
@@ -67,7 +70,7 @@ class GetPersons(Method):
         # Must query at least person_id, site_ids, and role_ids (see
         # Person.can_view() and below).
         if return_fields is not None:
-            added_fields = set(['person_id', 'site_ids', 'role_ids','roles']).difference(return_fields)
+            added_fields = set(['person_id', 'site_ids', 'role_ids', 'roles']).difference(return_fields)
             return_fields += added_fields
         else:
             added_fields = []