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 PasswordAuth
7 class AdmGetSitePersons(Method):
9 Return a list of person_ids for the site specified.
11 PIs may only retrieve the person_ids of accounts at their
12 site. Admins may retrieve the person_ids of accounts at any site.
15 roles = ['admin', 'pi']
19 Mixed(Site.fields['site_id'],
20 Site.fields['login_base'])
23 returns = Site.fields['person_ids']
25 def call(self, auth, site_id_or_login_base):
26 # Authenticated function
27 assert self.caller is not None
29 # Get site information
30 sites = Sites(self.api, [site_id_or_login_base]).values()
32 raise PLCInvalidArgument, "No such site"
36 if 'admin' not in self.caller['roles']:
37 if site['site_id'] not in self.caller['site_ids']:
38 raise PLCPermissionDenied, "Not allowed to view accounts at that site"
40 return site['person_ids']