From: Mark Huang Date: Wed, 18 Oct 2006 20:37:09 +0000 (+0000) Subject: UpdatePerson.py X-Git-Tag: pycurl-7_13_1~535 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=682e1251201c658ef45e38b0761fe79e787f2e3e;p=plcapi.git UpdatePerson.py --- diff --git a/PLC/Methods/AdmAddPerson.py b/PLC/Methods/AdmAddPerson.py index 7fd5db21..7858b8fe 100644 --- a/PLC/Methods/AdmAddPerson.py +++ b/PLC/Methods/AdmAddPerson.py @@ -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 index 00000000..d44f19ac --- /dev/null +++ b/PLC/Methods/AdmAddPersonKey.py @@ -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) diff --git a/PLC/Methods/AdmAddPersonToSite.py b/PLC/Methods/AdmAddPersonToSite.py index bde3dffc..948b06ff 100644 --- a/PLC/Methods/AdmAddPersonToSite.py +++ b/PLC/Methods/AdmAddPersonToSite.py @@ -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" diff --git a/PLC/Methods/AdmDeletePerson.py b/PLC/Methods/AdmDeletePerson.py index 8a4fd93e..ff29e8bd 100644 --- a/PLC/Methods/AdmDeletePerson.py +++ b/PLC/Methods/AdmDeletePerson.py @@ -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" diff --git a/PLC/Methods/AdmGetPersonRoles.py b/PLC/Methods/AdmGetPersonRoles.py index bfb7c470..16cc9bc2 100644 --- a/PLC/Methods/AdmGetPersonRoles.py +++ b/PLC/Methods/AdmGetPersonRoles.py @@ -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]) diff --git a/PLC/Methods/AdmGetPersonSites.py b/PLC/Methods/AdmGetPersonSites.py index c75a4321..78b5e028 100644 --- a/PLC/Methods/AdmGetPersonSites.py +++ b/PLC/Methods/AdmGetPersonSites.py @@ -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 diff --git a/PLC/Methods/AdmGetPersons.py b/PLC/Methods/AdmGetPersons.py index 03c1f15c..521c0ce2 100644 --- a/PLC/Methods/AdmGetPersons.py +++ b/PLC/Methods/AdmGetPersons.py @@ -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" diff --git a/PLC/Methods/AdmGetPowerControlUnitNodes.py b/PLC/Methods/AdmGetPowerControlUnitNodes.py index 9bd48f55..6d3ce361 100644 --- a/PLC/Methods/AdmGetPowerControlUnitNodes.py +++ b/PLC/Methods/AdmGetPowerControlUnitNodes.py @@ -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'])] diff --git a/PLC/Methods/AdmGrantRoleToPerson.py b/PLC/Methods/AdmGrantRoleToPerson.py index 7e10f881..569bf67c 100644 --- a/PLC/Methods/AdmGrantRoleToPerson.py +++ b/PLC/Methods/AdmGrantRoleToPerson.py @@ -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" diff --git a/PLC/Methods/AdmIsPersonInRole.py b/PLC/Methods/AdmIsPersonInRole.py index 24a00592..615546d5 100644 --- a/PLC/Methods/AdmIsPersonInRole.py +++ b/PLC/Methods/AdmIsPersonInRole.py @@ -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 diff --git a/PLC/Methods/AdmRemovePersonFromSite.py b/PLC/Methods/AdmRemovePersonFromSite.py index 66a64dff..54d3f1de 100644 --- a/PLC/Methods/AdmRemovePersonFromSite.py +++ b/PLC/Methods/AdmRemovePersonFromSite.py @@ -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" diff --git a/PLC/Methods/AdmRevokeRoleFromPerson.py b/PLC/Methods/AdmRevokeRoleFromPerson.py index cb7c2dfe..35b89d4f 100644 --- a/PLC/Methods/AdmRevokeRoleFromPerson.py +++ b/PLC/Methods/AdmRevokeRoleFromPerson.py @@ -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" diff --git a/PLC/Methods/AdmSetPersonEnabled.py b/PLC/Methods/AdmSetPersonEnabled.py index d97075bf..80e44963 100644 --- a/PLC/Methods/AdmSetPersonEnabled.py +++ b/PLC/Methods/AdmSetPersonEnabled.py @@ -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}) diff --git a/PLC/Methods/AdmSetPersonPrimarySite.py b/PLC/Methods/AdmSetPersonPrimarySite.py index 463afa57..c631a951 100644 --- a/PLC/Methods/AdmSetPersonPrimarySite.py +++ b/PLC/Methods/AdmSetPersonPrimarySite.py @@ -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" diff --git a/PLC/Methods/AdmUpdatePerson.py b/PLC/Methods/AdmUpdatePerson.py index 46c42677..066fe6d7 100644 --- a/PLC/Methods/AdmUpdatePerson.py +++ b/PLC/Methods/AdmUpdatePerson.py @@ -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" diff --git a/PLC/Methods/UpdatePerson.py b/PLC/Methods/UpdatePerson.py index 6ef7b701..36cb2c25 100644 --- a/PLC/Methods/UpdatePerson.py +++ b/PLC/Methods/UpdatePerson.py @@ -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: