1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Persons import Person, Persons
5 from PLC.Sites import Site, Sites
6 from PLC.Auth import Auth
8 class AdmGetPersonSites(Method):
10 Deprecated. See GetPersons.
12 Returns the sites that the specified person is associated with as
13 an array of site identifiers.
15 Admins may retrieve details about anyone. Users and techs may only
16 retrieve details about themselves. PIs may retrieve details about
17 themselves and others at their sites.
22 roles = ['admin', 'pi', 'user', 'tech']
26 Mixed(Person.fields['person_id'],
27 Person.fields['email'])
30 returns = Person.fields['site_ids']
32 def call(self, auth, person_id_or_email):
33 # Get account information
34 persons = Persons(self.api, [person_id_or_email])
36 raise PLCInvalidArgument, "No such account"
40 # Authenticated function
41 assert self.caller is not None
43 # Check if we can view this account
44 if not self.caller.can_view(person):
45 raise PLCPermissionDenied, "Not allowed to view specified account"
47 return person['site_ids']