X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddPersonKey.py;h=5212b44c7b920ee486039b0a4dbce5198c3525d7;hb=e085d19501505f72a95addbd4b099e8940505436;hp=0c3628466d67562652f3906be910302253b0a4dc;hpb=ac29a9eebfa173766903dbc8c06c01fc18335bab;p=plcapi.git diff --git a/PLC/Methods/AddPersonKey.py b/PLC/Methods/AddPersonKey.py index 0c36284..5212b44 100644 --- a/PLC/Methods/AddPersonKey.py +++ b/PLC/Methods/AddPersonKey.py @@ -1,3 +1,5 @@ +# $Id$ +# $URL$ from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed @@ -5,7 +7,7 @@ from PLC.Keys import Key, Keys from PLC.Persons import Person, Persons from PLC.Auth import Auth -can_update = lambda (field, value): field not in ['key_id'] +can_update = lambda (field, value): field in ['key_type','key'] class AddPersonKey(Method): """ @@ -29,7 +31,6 @@ class AddPersonKey(Method): returns = Parameter(int, 'New key_id (> 0) if successful') - def call(self, auth, person_id_or_email, key_fields): key_fields = dict(filter(can_update, key_fields.items())) @@ -42,7 +43,7 @@ class AddPersonKey(Method): if person['peer_id'] is not None: raise PLCInvalidArgument, "Not a local account" - # If we are not admin, make sure caller is adding a key to their account + # If we are not admin, make sure caller is adding a key to their account if 'admin' not in self.caller['roles']: if person['person_id'] != self.caller['person_id']: raise PLCPermissionDenied, "You may only modify your own keys" @@ -52,8 +53,9 @@ class AddPersonKey(Method): person.add_key(key, commit = True) # Logging variables - self.object_ids = [person['person_id'], key['key_id']] - self.message = 'Key %d added to person %d' % \ - (key['key_id'], person['person_id']) + self.event_objects = {'Person': [person['person_id']], + 'Key': [key['key_id']]} + self.message = 'Key %d added to person %d' % \ + (key['key_id'], person['person_id']) return key['key_id']