From: Mark Huang Date: Fri, 13 Oct 2006 20:01:06 +0000 (+0000) Subject: - silently remove fields that can't be updated from person_fields, for X-Git-Tag: pycurl-7_13_1~580 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ff621af0250f9508060692c188632b16c3882066;p=plcapi.git - silently remove fields that can't be updated from person_fields, for backward compatibility with AdmAddPerson --- diff --git a/PLC/Methods/AddPerson.py b/PLC/Methods/AddPerson.py index fb4b887b..d80826bc 100644 --- a/PLC/Methods/AddPerson.py +++ b/PLC/Methods/AddPerson.py @@ -4,9 +4,12 @@ from PLC.Parameter import Parameter, Mixed from PLC.Persons import Person, Persons from PLC.Auth import PasswordAuth +can_update = lambda (field, value): field in \ + ['title', 'email', 'password', 'phone', 'url', 'bio'] + class AddPerson(Method): """ - Adds a new account. Any fields specified in optional_vals are + Adds a new account. Any fields specified in person_fields are used, otherwise defaults are used. Accounts are disabled by default. To enable an account, use @@ -17,8 +20,6 @@ class AddPerson(Method): roles = ['admin', 'pi'] - can_update = lambda (field, value): field in \ - ['title', 'email', 'password', 'phone', 'url', 'bio'] update_fields = dict(filter(can_update, Person.fields.items())) accepts = [ @@ -30,11 +31,9 @@ class AddPerson(Method): returns = Parameter(int, 'New person_id (> 0) if successful') - def call(self, auth, first_name, last_name, optional_vals = {}): - if filter(lambda field: field not in self.update_fields, optional_vals): - raise PLCInvalidArgument, "Invalid fields specified" - - person = Person(self.api, optional_vals) + def call(self, auth, first_name, last_name, person_fields = {}): + person_fields = dict(filter(can_update, person_fields.items())) + person = Person(self.api, person_fields) person['first_name'] = first_name person['last_name'] = last_name person['enabled'] = False