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.Auth import Auth
7 class DeletePerson(Method):
9 Mark an existing account as deleted.
11 Users and techs can only delete themselves. PIs can only delete
12 themselves and other non-PIs at their sites. ins can delete
15 Returns 1 if successful, faults otherwise.
18 roles = ['admin', 'pi', 'user', 'tech']
22 Mixed(Person.fields['person_id'],
23 Person.fields['email'])
26 returns = Parameter(int, '1 if successful')
29 def call(self, auth, person_id_or_email):
30 # Get account information
31 persons = Persons(self.api, [person_id_or_email])
33 raise PLCInvalidArgument, "No such account"
36 PLCCheckLocalPerson(person,"DeletePerson")
38 # Authenticated function
39 assert self.caller is not None
41 # Check if we can update this account
42 if not self.caller.can_update(person):
43 raise PLCPermissionDenied, "Not allowed to delete specified account"
46 self.object_ids = [person['person_id']]