X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FDeletePerson.py;h=e85d2e9148f283b62de93d86b04872debad42f3e;hb=627477ce2065f9181498bd596e11d5179537bca5;hp=8375439bd80d92da143b81175a42a4c9d2e901e3;hpb=40d33ca5c3e174e3ac07e3519c07e43825b4c797;p=plcapi.git diff --git a/PLC/Methods/DeletePerson.py b/PLC/Methods/DeletePerson.py index 8375439..e85d2e9 100644 --- a/PLC/Methods/DeletePerson.py +++ b/PLC/Methods/DeletePerson.py @@ -2,7 +2,7 @@ from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.Persons import Person, Persons -from PLC.Auth import PasswordAuth +from PLC.Auth import Auth class DeletePerson(Method): """ @@ -18,7 +18,7 @@ class DeletePerson(Method): roles = ['admin', 'pi', 'user', 'tech'] accepts = [ - PasswordAuth(), + Auth(), Mixed(Person.fields['person_id'], Person.fields['email']) ] @@ -30,8 +30,10 @@ class DeletePerson(Method): persons = Persons(self.api, [person_id_or_email]) if not persons: raise PLCInvalidArgument, "No such account" + person = persons[0] - person = persons.values()[0] + if person['peer_id'] is not None: + raise PLCInvalidArgument, "Not a local account" # Authenticated function assert self.caller is not None @@ -42,4 +44,8 @@ class DeletePerson(Method): person.delete() + # Logging variables + self.event_objects = {'Person': [person['person_id']]} + self.message = 'Person %d deleted' % person['person_id'] + return 1