regenerate
[plcapi.git] / PLC / Methods / AdmAddPerson.py
index 7fd5db2..2b90f61 100644 (file)
@@ -2,42 +2,29 @@ from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.Persons import Person, Persons
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
+from PLC.Methods.AddPerson import AddPerson
 
-class AdmAddPerson(Method):
-    """
-    Adds a new account. Any fields specified in optional_vals are
-    used, otherwise defaults are used.
-
-    Accounts are disabled by default. To enable an account, use
-    AdmSetPersonEnabled() or AdmUpdatePerson().
+can_update = lambda (field, value): field in \
+             ['title', 'email', 'password', 'phone', 'url', 'bio']
 
-    Returns the new person_id (> 0) if successful, faults otherwise.
+class AdmAddPerson(AddPerson):
+    """
+    Deprecated. See AddPerson.
     """
 
-    roles = ['admin', 'pi']
+    status = "deprecated"
 
-    can_update = lambda (field, value): field in \
-                 ['title', 'email', 'password', 'phone', 'url', 'bio']
-    update_fields = dict(filter(can_update, Person.fields.items()))
+    person_fields = dict(filter(can_update, Person.fields.items()))
 
     accepts = [
-        PasswordAuth(),
+        Auth(),
         Person.fields['first_name'],
         Person.fields['last_name'],
-        update_fields
+        person_fields
         ]
 
-    returns = Parameter(int, 'New person_id (> 0) if successful')
-
-    def call(self, auth, first_name, last_name, optional_vals = {}):
-        if filter(lambda field: field not in self.update_fields, optional_vals):
-            raise PLCInvalidArgument, "Invalid fields specified"
-
-        person = Person(self.api, optional_vals)
-        person['first_name'] = first_name
-        person['last_name'] = last_name
-        person['enabled'] = False
-        person.sync()
-
-        return person['person_id']
+    def call(self, auth, first_name, last_name, person_fields = {}):
+        person_fields['first_name'] = first_name
+        person_fields['last_name'] = last_name
+        return AddPerson.call(self, auth, person_fields)