UpdatePerson.py
authorMark Huang <mlhuang@cs.princeton.edu>
Wed, 18 Oct 2006 20:37:09 +0000 (20:37 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Wed, 18 Oct 2006 20:37:09 +0000 (20:37 +0000)
16 files changed:
PLC/Methods/AdmAddPerson.py
PLC/Methods/AdmAddPersonKey.py [new file with mode: 0644]
PLC/Methods/AdmAddPersonToSite.py
PLC/Methods/AdmDeletePerson.py
PLC/Methods/AdmGetPersonRoles.py
PLC/Methods/AdmGetPersonSites.py
PLC/Methods/AdmGetPersons.py
PLC/Methods/AdmGetPowerControlUnitNodes.py
PLC/Methods/AdmGrantRoleToPerson.py
PLC/Methods/AdmIsPersonInRole.py
PLC/Methods/AdmRemovePersonFromSite.py
PLC/Methods/AdmRevokeRoleFromPerson.py
PLC/Methods/AdmSetPersonEnabled.py
PLC/Methods/AdmSetPersonPrimarySite.py
PLC/Methods/AdmUpdatePerson.py
PLC/Methods/UpdatePerson.py

index 7fd5db2..7858b8f 100644 (file)
@@ -1,43 +1,8 @@
-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.Methods.AddPerson import AddPerson
 
-class AdmAddPerson(Method):
+class AdmAddPerson(AddPerson):
     """
-    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().
-
-    Returns the new person_id (> 0) if successful, faults otherwise.
+    Deprecated. See AddPerson.
     """
 
-    roles = ['admin', 'pi']
-
-    can_update = lambda (field, value): field in \
-                 ['title', 'email', 'password', 'phone', 'url', 'bio']
-    update_fields = dict(filter(can_update, Person.fields.items()))
-
-    accepts = [
-        PasswordAuth(),
-        Person.fields['first_name'],
-        Person.fields['last_name'],
-        update_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']
+    status = "deprecated"
diff --git a/PLC/Methods/AdmAddPersonKey.py b/PLC/Methods/AdmAddPersonKey.py
new file mode 100644 (file)
index 0000000..d44f19a
--- /dev/null
@@ -0,0 +1,26 @@
+from PLC.Faults import *
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.Keys import Key, Keys
+from PLC.Persons import Person, Persons
+from PLC.Auth import PasswordAuth
+
+class AdmAddPersonKey(AddPersonKey):
+    """
+    Deprecated. See AddPersonKey. Keys can no longer be marked as
+    primary, i.e. the is_primary argument does nothing.
+    """
+
+    status = "deprecated"
+
+    accepts = [
+        PasswordAuth(),
+        Mixed(Person.fields['person_id'],
+              Person.fields['email']),
+        Key.fields['key_type'],
+        Key.fields['key'],
+        Parameter(int, "Make this key the primary key")
+        ]
+
+    def call(self, auth, person_id_or_email, key_type, key_value, is_primary):
+        return AddPersonKey.call(self, auth, person_id_or_email, key_type, key_value)
index bde3dff..948b06f 100644 (file)
@@ -1,47 +1,8 @@
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Persons import Person, Persons
-from PLC.Sites import Site, Sites
-from PLC.Auth import PasswordAuth
+from PLC.Methods.AddPersonToSite import AddPersonToSite
 
-class AdmAddPersonToSite(Method):
+class AdmAddPersonToSite(AddPersonToSite):
     """
-    Adds the specified person to the specified site. If the person is
-    already a member of the site, no errors are returned. Does not
-    change the person's primary site.
-
-    Returns 1 if successful, faults otherwise.
+    Deprecated. See AddPersonToSite.
     """
 
-    roles = ['admin']
-
-    accepts = [
-        PasswordAuth(),
-        Mixed(Person.fields['person_id'],
-              Person.fields['email']),
-        Mixed(Site.fields['site_id'],
-              Site.fields['login_base'])
-        ]
-
-    returns = Parameter(int, '1 if successful')
-
-    def call(self, auth, person_id_or_email, site_id_or_login_base):
-        # Get account information
-        persons = Persons(self.api, [person_id_or_email])
-        if not persons:
-            raise PLCInvalidArgument, "No such account"
-
-        person = persons.values()[0]
-
-        # Get site information
-        sites = Sites(self.api, [site_id_or_login_base])
-        if not sites:
-            raise PLCInvalidArgument, "No such site"
-
-        site = sites.values()[0]
-
-        if site['site_id'] not in person['site_ids']:
-            site.add_person(person)
-
-        return 1
+    status = "deprecated"
index 8a4fd93..ff29e8b 100644 (file)
@@ -1,45 +1,8 @@
-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.Methods.DeletePerson import DeletePerson
 
-class AdmDeletePerson(Method):
+class AdmDeletePerson(DeletePerson):
     """
-    Mark an existing account as deleted.
-
-    Users and techs can only delete themselves. PIs can only delete
-    themselves and other non-PIs at their sites. Admins can delete
-    anyone.
-
-    Returns 1 if successful, faults otherwise.
+    Deprecated. See DeletePerson.
     """
 
-    roles = ['admin', 'pi', 'user', 'tech']
-
-    accepts = [
-        PasswordAuth(),
-        Mixed(Person.fields['person_id'],
-              Person.fields['email'])
-        ]
-
-    returns = Parameter(int, '1 if successful')
-
-    def call(self, auth, person_id_or_email):
-        # Get account information
-        persons = Persons(self.api, [person_id_or_email])
-        if not persons:
-            raise PLCInvalidArgument, "No such account"
-
-        person = persons.values()[0]
-
-        # Authenticated function
-        assert self.caller is not None
-
-        # Check if we can update this account
-        if not self.caller.can_update(person):
-            raise PLCPermissionDenied, "Not allowed to delete specified account"
-
-        person.delete()
-
-        return 1
+    status = "deprecated"
index bfb7c47..16cc9bc 100644 (file)
@@ -6,6 +6,8 @@ from PLC.Auth import PasswordAuth
 
 class AdmGetPersonRoles(Method):
     """
+    Deprecated. See GetPersons.
+
     Return the roles that the specified person has as a struct:
 
     {'10': 'admin', '30': 'user', '20': 'pi', '40': 'tech'}
@@ -19,6 +21,8 @@ class AdmGetPersonRoles(Method):
     identifiers.
     """
 
+    status = "deprecated"
+
     roles = ['admin', 'pi', 'user', 'tech']
 
     accepts = [
@@ -29,10 +33,6 @@ class AdmGetPersonRoles(Method):
 
     returns = dict
 
-    # Stupid return type, and can get now roles through
-    # AdmGetPersons().
-    status = "useless"
-
     def call(self, auth, person_id_or_email):
         # Get account information
         persons = Persons(self.api, [person_id_or_email])
index c75a432..78b5e02 100644 (file)
@@ -7,6 +7,8 @@ from PLC.Auth import PasswordAuth
 
 class AdmGetPersonSites(Method):
     """
+    Deprecated. See GetPersons.
+
     Returns the sites that the specified person is associated with as
     an array of site identifiers.
 
@@ -15,15 +17,13 @@ class AdmGetPersonSites(Method):
     themselves and others at their sites.
     """
 
-    roles = ['admin', 'pi', 'user', 'tech']
-
     accepts = [
         PasswordAuth(),
         Mixed(Person.fields['person_id'],
               Person.fields['email'])
         ]
 
-    returns = [Site.fields['site_id']]
+    returns = Person.fields['site_ids']
 
     def call(self, auth, person_id_or_email):
         # Get account information
index 03c1f15..521c0ce 100644 (file)
@@ -1,71 +1,8 @@
-import os
+from PLC.Methods.GetPersons import GetPersons
 
-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
-
-class AdmGetPersons(Method):
+class AdmGetPersons(GetPersons):
     """
-    Return an array of dictionaries containing details about the
-    specified accounts.
-
-    Admins may retrieve details about all accounts by not specifying
-    person_id_or_email_list or by specifying an empty list. Users and
-    techs may only retrieve details about themselves. PIs may retrieve
-    details about themselves and others at their sites.
-
-    If return_fields is specified, only the specified fields will be
-    returned, if set. Otherwise, the default set of fields returned is:
-
+    Deprecated. See GetPersons.
     """
 
-    roles = ['admin', 'pi', 'user', 'tech']
-
-    accepts = [
-        PasswordAuth(),
-        [Mixed(Person.fields['person_id'],
-               Person.fields['email'])],
-        Parameter([str], 'List of fields to return')
-        ]
-
-    # Filter out password field
-    can_return = lambda (field, value): field not in ['password']
-    return_fields = dict(filter(can_return, Person.fields.items()))
-    returns = [return_fields]
-
-    def __init__(self, *args, **kwds):
-        Method.__init__(self, *args, **kwds)
-        # Update documentation with list of default fields returned
-        self.__doc__ += os.linesep.join(self.return_fields.keys())
-
-    def call(self, auth, person_id_or_email_list = None, return_fields = None):
-        # Make sure that only valid fields are specified
-        if return_fields is None:
-            return_fields = self.return_fields
-        elif filter(lambda field: field not in self.return_fields, return_fields):
-            raise PLCInvalidArgument, "Invalid return field specified"
-
-        # Authenticated function
-        assert self.caller is not None
-
-        # Only admins can not specify person_id_or_email_list or
-        # specify an empty list.
-        if not person_id_or_email_list and 'admin' not in self.caller['roles']:
-            raise PLCInvalidArgument, "List of accounts to retrieve not specified"
-
-        # Get account information
-        persons = Persons(self.api, person_id_or_email_list)
-
-        # Filter out accounts that are not viewable and turn into list
-        persons = filter(self.caller.can_view, persons.values())
-
-        # Filter out undesired or None fields (XML-RPC cannot marshal
-        # None) and turn each person into a real dict.
-        valid_return_fields_only = lambda (key, value): \
-                                   key in return_fields and value is not None
-        persons = [dict(filter(valid_return_fields_only, person.items())) \
-                   for person in persons]
-                    
-        return persons
+    status = "deprecated"
index 9bd48f5..6d3ce36 100644 (file)
@@ -3,9 +3,8 @@ from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.PCUs import PCU, PCUs
 from PLC.Auth import PasswordAuth
-from PLC.Methods.GetPCUs import GetPCUs
 
-class AdmGetPowerControlUnitNodes(GetPCUs):
+class AdmGetPowerControlUnitNodes(Method):
     """
     Deprecated. See GetPCUs.
 
@@ -27,10 +26,14 @@ class AdmGetPowerControlUnitNodes(GetPCUs):
                 'port_number': Parameter(int, "Port number")}]
 
     def call(self, auth, pcu_id):
-        pcus = GetPCUs.call(self, auth, [pcu_id])
+        pcus = PCUs(self.api, [pcu_id]).values()
         if not pcus:
             raise PLCInvalidArgument, "No such PCU"
         pcu = pcus[0]
 
+        if 'admin' not in self.caller['roles']:
+            if pcu['site_id'] not in self.caller['site_ids']:
+                raise PLCPermissionDenied, "Not allowed to view that PCU"
+
         return [{'node_id': node_id, 'port_number': port} \
                 for (node_id, port) in zip(pcu['node_ids'], pcu['ports'])]
index 7e10f88..569bf67 100644 (file)
@@ -1,67 +1,8 @@
-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.Roles import Roles
+from PLC.Methods.AddRoleToPerson import AddRoleToPerson
 
-class AdmGrantRoleToPerson(Method):
+class AdmGrantRoleToPerson(AddRoleToPerson):
     """
-    Grants the specified role to the person.
-    
-    PIs can only grant the tech and user roles to users and techs at
-    their sites. Admins can grant any role to any user.
-
-    Returns 1 if successful, faults otherwise.
+    Deprecated. See AddRoleToPerson.
     """
 
-    roles = ['admin', 'pi']
-
-    accepts = [
-        PasswordAuth(),
-        Mixed(Person.fields['person_id'],
-              Person.fields['email']),
-        Mixed(Parameter(int, "Role identifier"),
-              Parameter(str, "Role name"))
-        ]
-
-    returns = Parameter(int, '1 if successful')
-
-    def call(self, auth, person_id_or_email, role_id_or_name):
-        # Get all roles
-        roles = {}
-        for role_id, role in Roles(self.api).iteritems():
-            roles[role_id] = role['name']
-            roles[role['name']] = role_id
-
-        if role_id_or_name not in roles:
-            raise PLCInvalidArgument, "Invalid role identifier or name"
-
-        if isinstance(role_id_or_name, int):
-            role_id = role_id_or_name
-        else:
-            role_id = roles[role_id_or_name]
-
-        # Get account information
-        persons = Persons(self.api, [person_id_or_email])
-        if not persons:
-            raise PLCInvalidArgument, "No such account"
-
-        person = persons.values()[0]
-
-        # Authenticated function
-        assert self.caller is not None
-
-        # Check if we can update this account
-        if not self.caller.can_update(person):
-            raise PLCPermissionDenied, "Not allowed to update specified account"
-
-        # Can only grant lesser (higher) roles to others
-        if 'admin' not in self.caller['roles'] and \
-           role_id <= min(self.caller['role_ids']):
-            raise PLCInvalidArgument, "Not allowed to grant that role"
-
-        if role_id not in person['role_ids']:
-            person.add_role(role_id)
-
-        return 1
+    status = "deprecated"
index 24a0059..615546d 100644 (file)
@@ -1,5 +1,3 @@
-from types import StringTypes
-
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
@@ -9,12 +7,16 @@ from PLC.Roles import Role, Roles
 
 class AdmIsPersonInRole(Method):
     """
+    Deprecated. Functionality can be implemented with GetPersons.
+
     Returns 1 if the specified account has the specified role, 0
     otherwise. This function differs from AdmGetPersonRoles() in that
     any authorized user can call it. It is currently restricted to
     verifying PI roles.
     """
 
+    status = "deprecated"
+
     roles = ['admin', 'pi', 'user', 'tech']
 
     accepts = [
@@ -27,8 +29,6 @@ class AdmIsPersonInRole(Method):
 
     returns = Parameter(int, "1 if account has role, 0 otherwise")
 
-    status = "useless"
-
     def call(self, auth, person_id_or_email, role_id_or_name):
         # This is a totally fucked up function. I have no idea why it
         # exists or who calls it, but here is how it is supposed to
index 66a64df..54d3f1d 100644 (file)
@@ -1,47 +1,8 @@
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Persons import Person, Persons
-from PLC.Sites import Site, Sites
-from PLC.Auth import PasswordAuth
+from PLC.Methods.DeletePersonFromSite import DeletePersonFromSite
 
-class AdmRemovePersonFromSite(Method):
+class AdmRemovePersonFromSite(DeletePersonFromSite):
     """
-    Removes the specified person from the specified site. If the
-    person is not a member of the specified site, no error is
-    returned.
-
-    Returns 1 if successful, faults otherwise.
+    Deprecated. See DeletePersonFromSite.
     """
 
-    roles = ['admin']
-
-    accepts = [
-        PasswordAuth(),
-        Mixed(Person.fields['person_id'],
-              Person.fields['email']),
-        Mixed(Site.fields['site_id'],
-              Site.fields['login_base'])
-        ]
-
-    returns = Parameter(int, '1 if successful')
-
-    def call(self, auth, person_id_or_email, site_id_or_login_base):
-        # Get account information
-        persons = Persons(self.api, [person_id_or_email])
-        if not persons:
-            raise PLCInvalidArgument, "No such account"
-
-        person = persons.values()[0]
-
-        # Get site information
-        sites = Sites(self.api, [site_id_or_login_base])
-        if not sites:
-            raise PLCInvalidArgument, "No such site"
-
-        site = sites.values()[0]
-
-        if site['site_id'] in person['site_ids']:
-            site.remove_person(person)
-
-        return 1
+    status = "deprecated"
index cb7c2df..35b89d4 100644 (file)
@@ -1,67 +1,8 @@
-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.Roles import Roles
+from PLC.Methods.DeleteRoleFromPerson import DeleteRoleFromPerson
 
-class AdmRevokeRoleFromPerson(Method):
+class AdmRevokeRoleFromPerson(DeleteRoleFromPerson):
     """
-    Revokes the specified role from the person.
-    
-    PIs can only revoke the tech and user roles from users and techs
-    at their sites. Admins can revoke any role from any user.
-
-    Returns 1 if successful, faults otherwise.
+    Deprecated. See DeleteRoleFromPerson.
     """
 
-    roles = ['admin', 'pi']
-
-    accepts = [
-        PasswordAuth(),
-        Mixed(Person.fields['person_id'],
-              Person.fields['email']),
-        Mixed(Parameter(int, "Role identifier"),
-              Parameter(str, "Role name"))
-        ]
-
-    returns = Parameter(int, '1 if successful')
-
-    def call(self, auth, person_id_or_email, role_id_or_name):
-        # Get all roles
-        roles = {}
-        for role_id, role in Roles(self.api).iteritems():
-            roles[role_id] = role['name']
-            roles[role['name']] = role_id
-
-        if role_id_or_name not in roles:
-            raise PLCInvalidArgument, "Invalid role identifier or name"
-
-        if isinstance(role_id_or_name, int):
-            role_id = role_id_or_name
-        else:
-            role_id = roles[role_id_or_name]
-
-        # Get account information
-        persons = Persons(self.api, [person_id_or_email])
-        if not persons:
-            raise PLCInvalidArgument, "No such account"
-
-        person = persons.values()[0]
-
-        # Authenticated function
-        assert self.caller is not None
-
-        # Check if we can update this account
-        if not self.caller.can_update(person):
-            raise PLCPermissionDenied, "Not allowed to update specified account"
-
-        # Can only revoke lesser (higher) roles from others
-        if 'admin' not in self.caller['roles'] and \
-           role_id <= min(self.caller['role_ids']):
-            raise PLCPermissionDenied, "Not allowed to revoke that role"
-
-        if role_id in person['role_ids']:
-            person.remove_role(role_id)
-
-        return 1
+    status = "deprecated"
index d97075b..80e4496 100644 (file)
@@ -1,21 +1,11 @@
-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.Methods.UpdatePerson import UpdatePerson
 
-class AdmSetPersonEnabled(Method):
+class AdmSetPersonEnabled(UpdatePerson):
     """
-    Enables or disables a person.
-
-    Users and techs can only update themselves. PIs can only update
-    themselves and other non-PIs at their sites. Admins can update
-    anyone.
-
-    Returns 1 if successful, faults otherwise.
+    Deprecated. See UpdatePerson.
     """
 
-    roles = ['admin', 'pi']
+    status = "deprecated"
 
     accepts = [
         PasswordAuth(),
@@ -24,24 +14,5 @@ class AdmSetPersonEnabled(Method):
         Person.fields['enabled']
         ]
 
-    returns = Parameter(int, '1 if successful')
-
     def call(self, auth, person_id_or_email, enabled):
-        # Get account information
-        persons = Persons(self.api, [person_id_or_email])
-        if not persons:
-            raise PLCInvalidArgument, "No such account"
-
-        person = persons.values()[0]
-
-        # Authenticated function
-        assert self.caller is not None
-
-        # Check if we can update this account
-        if not self.caller.can_update(person):
-            raise PLCPermissionDenied, "Not allowed to enable specified account"
-
-        person['enabled'] = enabled
-        person.sync()
-
-        return 1
+        return UpdatePerson.call(self, auth, person_id_or_email, {'enabled': enabled})
index 463afa5..c631a95 100644 (file)
@@ -1,56 +1,8 @@
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Persons import Person, Persons
-from PLC.Sites import Site, Sites
-from PLC.Auth import PasswordAuth
+from PLC.Methods.SetPersonPrimarySite import SetPersonPrimarySite
 
-class AdmSetPersonPrimarySite(Method):
+class AdmSetPersonPrimarySite(SetPersonPrimarySite):
     """
-    Makes the specified site the person's primary site. The person
-    must already be a member of the site.
-
-    Admins may update anyone. All others may only update themselves.
+    Deprecated. See SetPersonPrimarySite.
     """
 
-    roles = ['admin', 'pi', 'user', 'tech']
-
-    accepts = [
-        PasswordAuth(),
-        Mixed(Person.fields['person_id'],
-              Person.fields['email']),
-        Mixed(Site.fields['site_id'],
-              Site.fields['login_base'])
-        ]
-
-    returns = Parameter(int, '1 if successful')
-
-    def call(self, auth, person_id_or_email, site_id_or_login_base):
-        # Get account information
-        persons = Persons(self.api, [person_id_or_email])
-        if not persons:
-            raise PLCInvalidArgument, "No such account"
-
-        person = persons.values()[0]
-
-        # Authenticated function
-        assert self.caller is not None
-
-        # Non-admins can only update their own primary site
-        if 'admin' not in self.caller['roles'] and \
-           self.caller['person_id'] != person['person_id']:
-            raise PLCPermissionDenied, "Not allowed to update specified account"
-
-        # Get site information
-        sites = Sites(self.api, [site_id_or_login_base])
-        if not sites:
-            raise PLCInvalidArgument, "No such site"
-
-        site = sites.values()[0]
-
-        if site['site_id'] not in person['site_ids']:
-            raise PLCInvalidArgument, "Not a member of the specified site"
-
-        person.set_primary_site(site)
-
-        return 1
+    status = "deprecated"
index 46c4267..066fe6d 100644 (file)
@@ -1,68 +1,8 @@
-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.Methods.UpdatePerson import UpdatePerson
 
-class AdmUpdatePerson(Method):
+class AdmUpdatePerson(UpdatePerson):
     """
-    Updates a person. Only the fields specified in update_fields are
-    updated, all other fields are left untouched.
-
-    To remove a value without setting a new one in its place (for
-    example, to remove an address from the person), specify -1 for int
-    and double fields and 'null' for string fields. first_name and
-    last_name cannot be unset.
-    
-    Users and techs can only update themselves. PIs can only update
-    themselves and other non-PIs at their sites.
-
-    Returns 1 if successful, faults otherwise.
+    Deprecated. See UpdatePerson.
     """
 
-    roles = ['admin', 'pi', 'user', 'tech']
-
-    can_update = lambda (field, value): field in \
-                 ['first_name', 'last_name', 'title', 'email',
-                  'password', 'phone', 'url', 'bio', 'accepted_aup']
-    update_fields = dict(filter(can_update, Person.fields.items()))
-
-    accepts = [
-        PasswordAuth(),
-        Mixed(Person.fields['person_id'],
-              Person.fields['email']),
-        update_fields
-        ]
-
-    returns = Parameter(int, '1 if successful')
-
-    def call(self, auth, person_id_or_email, update_fields):
-        if filter(lambda field: field not in self.update_fields, update_fields):
-            raise PLCInvalidArgument, "Invalid field specified"
-
-        # XML-RPC cannot marshal None, so we need special values to
-        # represent "unset".
-        for key, value in update_fields.iteritems():
-            if value == -1 or value == "null":
-                if key in ['first_name', 'last_name']:
-                    raise PLCInvalidArgument, "first_name and last_name cannot be unset"
-                update_fields[key] = None
-
-        # Get account information
-        persons = Persons(self.api, [person_id_or_email])
-        if not persons:
-            raise PLCInvalidArgument, "No such account"
-
-        person = persons.values()[0]
-
-        # Authenticated function
-        assert self.caller is not None
-
-        # Check if we can update this account
-        if not self.caller.can_update(person):
-            raise PLCPermissionDenied, "Not allowed to update specified account"
-
-        person.update(update_fields)
-        person.sync()
-
-        return 1
+    status = "deprecated"
index 6ef7b70..36cb2c2 100644 (file)
@@ -41,11 +41,6 @@ class UpdatePerson(Method):
     def call(self, auth, person_id_or_email, person_fields):
         person_fields = dict(filter(can_update, person_fields.items()))
 
-       # Remove admin only fields
-       if 'admin' not in self.caller['roles']:
-            for key in ['enabled']:
-                del person_fields[key]
-
         # Get account information
         persons = Persons(self.api, [person_id_or_email])
         if not persons: