From: Marco Yuen Date: Mon, 1 Oct 2012 13:23:54 +0000 (-0400) Subject: Implement AddPersonKey X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=a726c8260e6da507a165a1f58cf4f50e4aa61a35;p=plcapi.git Implement AddPersonKey --- diff --git a/PLC/Methods/AddPersonKey.py b/PLC/Methods/AddPersonKey.py index af701859..6dd587dc 100644 --- a/PLC/Methods/AddPersonKey.py +++ b/PLC/Methods/AddPersonKey.py @@ -5,7 +5,7 @@ from PLC.Keys import Key, Keys from PLC.Persons import Person, Persons from PLC.Auth import Auth -can_update = lambda (field, value): field in ['key_type','key'] +can_update = lambda (field, value): field in ['key_type', 'key', 'key_id'] class AddPersonKey(Method): """ @@ -27,7 +27,7 @@ class AddPersonKey(Method): key_fields ] - returns = Parameter(int, 'New key_id (> 0) if successful') + returns = Parameter(str, 'The key_id') def call(self, auth, person_id_or_email, key_fields): key_fields = dict(filter(can_update, key_fields.items())) @@ -47,8 +47,8 @@ class AddPersonKey(Method): raise PLCPermissionDenied, "You may only modify your own keys" key = Key(self.api, key_fields) - key.sync(commit = False) - person.add_key(key, commit = True) + key.sync(insert = True) + #person.add_key(key, commit = True) # Logging variables self.event_objects = {'Person': [person['person_id']],