X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FGetPersons.py;h=263c66359429dd72013a5c790c489cff6a417de7;hb=e70e20fdbececafef842ec7b330fd48db42e614e;hp=a209b879077aae2053dc5c8c1331e9b16d8eafb2;hpb=e0db215cc39b60892f0b674ca0e7607f6df66d58;p=plcapi.git diff --git a/PLC/Methods/GetPersons.py b/PLC/Methods/GetPersons.py index a209b87..263c663 100644 --- a/PLC/Methods/GetPersons.py +++ b/PLC/Methods/GetPersons.py @@ -5,6 +5,7 @@ from PLC.Filter import Filter from PLC.Persons import Person, Persons from PLC.Sites import Site, Sites from PLC.Auth import Auth +from PLC.Logger import logger hidden_fields = ['password', 'verification_key', 'verification_expires'] @@ -39,21 +40,28 @@ class GetPersons(Method): returns = [return_fields] def call(self, auth, person_filter = None, return_fields = None): + + logger.info("incoming GetPersons, filter={}, return fields={}" + .format(person_filter, return_fields)) + # If we are not admin, make sure to only return viewable accounts if isinstance(self.caller, Person) and \ '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 [] - # 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