- make Add() calling convention consistent among all functions that
[plcapi.git] / PLC / Methods / AddAddressType.py
index 075fca2..373f804 100644 (file)
@@ -4,7 +4,7 @@ from PLC.Parameter import Parameter, Mixed
 from PLC.AddressTypes import AddressType, AddressTypes
 from PLC.Auth import PasswordAuth
 
-can_update = lambda (field, value): field in ['description']
+can_update = lambda (field, value): field not in ['address_type_id']
 
 class AddAddressType(Method):
     """
@@ -16,12 +16,11 @@ class AddAddressType(Method):
 
     roles = ['admin']
 
-    update_fields = dict(filter(can_update, AddressType.fields.items()))
+    address_type_fields = dict(filter(can_update, AddressType.fields.items()))
 
     accepts = [
         PasswordAuth(),
-        AddressType.fields['name'],
-        update_fields
+        address_type_fields
         ]
 
     returns = Parameter(int, 'New address_type_id (> 0) if successful')
@@ -30,11 +29,11 @@ class AddAddressType(Method):
     object_type = 'AddressType'
     object_ids = []
 
-    def call(self, auth, name, address_type_fields = {}):
+    def call(self, auth, address_type_fields = {}):
         address_type_fields = dict(filter(can_update, address_type_fields.items()))
         address_type = AddressType(self.api, address_type_fields)
-        address_type['name'] = name
         address_type.sync()
+
        self.object_ids = [address_type['address_type_id']]
         
        return address_type['address_type_id']