1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Sites import Site, Sites
5 from PLC.Auth import Auth
7 class AdmGetSitePersons(Method):
9 Deprecated. See GetSites.
11 Return a list of person_ids for the site specified.
13 PIs may only retrieve the person_ids of accounts at their
14 site. Admins may retrieve the person_ids of accounts at any site.
19 roles = ['admin', 'pi']
23 Mixed(Site.fields['site_id'],
24 Site.fields['login_base'])
27 returns = Site.fields['person_ids']
29 def call(self, auth, site_id_or_login_base):
30 # Authenticated function
31 assert self.caller is not None
33 # Get site information
34 sites = Sites(self.api, [site_id_or_login_base]).values()
36 raise PLCInvalidArgument, "No such site"
40 if 'admin' not in self.caller['roles']:
41 if site['site_id'] not in self.caller['site_ids']:
42 raise PLCPermissionDenied, "Not allowed to view accounts at that site"
44 return site['person_ids']