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
6 import uuid ##################################soners
8 can_update = lambda (field, value): field in \
9 ['first_name', 'last_name', 'title',
10 'email', 'password', 'phone', 'url', 'bio']
12 class AddPerson(Method):
14 Adds a new account. Any fields specified in person_fields are
15 used, otherwise defaults are used.
17 Accounts are disabled by default. To enable an account, use
20 Returns the new person_id (> 0) if successful, faults otherwise.
23 roles = ['admin', 'pi']
25 person_fields = dict(filter(can_update, Person.fields.items()))
32 returns = Parameter(int, 'New person_id (> 0) if successful')
34 def call(self, auth, person_fields):
35 person_fields = dict(filter(can_update, person_fields.items()))
36 person_fields['uuid'] = str(uuid.uuid4().int)###############################soners
37 person_fields['enabled'] = False
38 person = Person(self.api, person_fields)
42 self.event_objects = {'Person': [person['person_id']]}
43 self.message = 'Person %d added' % person['person_id']
45 return person['person_id']