3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.Sites import Site, Sites
7 from PLC.Auth import PasswordAuth
9 class AdmGetSitePersons(Method):
11 Return a list of person_ids for the site specified.
13 Admins may retrieve person_ids at any site by not specifying
14 site_id_or_name or by specifying an empty list. PIs may only retrieve
15 the person_ids at their site
19 roles = ['admin', 'pi']
23 Site.fields['site_id']
26 returns = [Site.all_fields['person_ids']]
28 def call(self, auth, site_id):
29 # Authenticated function
30 assert self.caller is not None
32 # Get site information
33 sites = Sites(self.api, [site_id], ['person_ids']).values()
35 # make sure sites are found
37 raise PLCInvalidArgument, "No such site"
39 if 'admin' not in self.caller['roles']:
40 if site['site_id'] not in self.caller['site_ids']:
41 raise PLCPermissionDenied, "Not allowed to update node network"
42 person_ids = site['person_ids']