Implement AddPersonKey
authorMarco Yuen <marcoy@gmail.com>
Mon, 1 Oct 2012 13:23:54 +0000 (09:23 -0400)
committerMarco Yuen <marcoy@gmail.com>
Mon, 1 Oct 2012 13:23:54 +0000 (09:23 -0400)
PLC/Methods/AddPersonKey.py

index af70185..6dd587d 100644 (file)
@@ -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']],