X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FUpdateAddressType.py;h=922c9409bf47ebd921851d4a7ddafda710603195;hb=dc284781b50951778096561befcaa1bd33394168;hp=7e7143124d2affa19bd36520c1a951a6784ffaea;hpb=ed7fa1ebf97ec2f88f18f8fa538e46c6ae9525c4;p=plcapi.git diff --git a/PLC/Methods/UpdateAddressType.py b/PLC/Methods/UpdateAddressType.py index 7e71431..922c940 100644 --- a/PLC/Methods/UpdateAddressType.py +++ b/PLC/Methods/UpdateAddressType.py @@ -2,7 +2,7 @@ from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.AddressTypes import AddressType, AddressTypes -from PLC.Auth import PasswordAuth +from PLC.Auth import Auth can_update = lambda (field, value): field in ['name', 'description'] @@ -17,11 +17,9 @@ class UpdateAddressType(Method): roles = ['admin'] address_type_fields = dict(filter(can_update, AddressType.fields.items())) - for field in address_type_fields.values(): - field.optional = True accepts = [ - PasswordAuth(), + Auth(), Mixed(AddressType.fields['address_type_id'], AddressType.fields['name']), address_type_fields @@ -32,12 +30,13 @@ class UpdateAddressType(Method): def call(self, auth, address_type_id_or_name, address_type_fields): address_type_fields = dict(filter(can_update, address_type_fields.items())) - address_types = AddressTypes(self.api, [address_type_id_or_name]).values() + address_types = AddressTypes(self.api, [address_type_id_or_name]) if not address_types: raise PLCInvalidArgument, "No such address type" address_type = address_types[0] address_type.update(address_type_fields) address_type.sync() + self.event_objects = {'AddressType': [address_type['address_type_id']]} return 1