X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=PLC%2FMethods%2FAddPerson.py;h=bd634cbeea59b64cf8bb0f58130f351756215b27;hb=2e7b23eea75847d91f079372191b9fcc822d7d8e;hp=6af541b33336212fe67b073062b27f833e15046c;hpb=ed7fa1ebf97ec2f88f18f8fa538e46c6ae9525c4;p=plcapi.git diff --git a/PLC/Methods/AddPerson.py b/PLC/Methods/AddPerson.py index 6af541b..bd634cb 100644 --- a/PLC/Methods/AddPerson.py +++ b/PLC/Methods/AddPerson.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 can_update = lambda (field, value): field in \ ['first_name', 'last_name', 'title', @@ -14,7 +14,7 @@ class AddPerson(Method): used, otherwise defaults are used. Accounts are disabled by default. To enable an account, use - SetPersonEnabled() or UpdatePerson(). + UpdatePerson(). Returns the new person_id (> 0) if successful, faults otherwise. """ @@ -24,21 +24,23 @@ class AddPerson(Method): person_fields = dict(filter(can_update, Person.fields.items())) accepts = [ - PasswordAuth(), + Auth(), person_fields ] returns = Parameter(int, 'New person_id (> 0) if successful') - event_type = 'Add' object_type = 'Person' - object_ids = [] - def call(self, auth, person_fields = {}): + + def call(self, auth, person_fields): person_fields = dict(filter(can_update, person_fields.items())) + person_fields['enabled'] = False person = Person(self.api, person_fields) person.sync() + # Logging variables self.object_ids = [person['person_id']] + self.message = 'Person %d added' % person['person_id'] return person['person_id']