X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FSetPersonPrimarySite.py;h=644826b676acad9359589665ddbce3ba7f3abd53;hb=4e770b3cf4e6b16150fd479ace9854eaee3399b6;hp=61ab28713caf5997fce079d4bb0afda0ed09cd7d;hpb=e347fc823bbba9d88a3fddf07d5c21024dfd1e55;p=plcapi.git diff --git a/PLC/Methods/SetPersonPrimarySite.py b/PLC/Methods/SetPersonPrimarySite.py index 61ab287..644826b 100644 --- a/PLC/Methods/SetPersonPrimarySite.py +++ b/PLC/Methods/SetPersonPrimarySite.py @@ -10,7 +10,7 @@ class SetPersonPrimarySite(Method): Makes the specified site the person's primary site. The person must already be a member of the site. - ins may update anyone. All others may only update themselves. + Admins may update anyone. All others may only update themselves. """ roles = ['admin', 'pi', 'user', 'tech'] @@ -25,14 +25,18 @@ class SetPersonPrimarySite(Method): returns = Parameter(int, '1 if successful') + object_type = 'Person' + 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[0] + if person['peer_id'] is not None: + raise PLCInvalidArgument, "Not a local account" + # Authenticated function assert self.caller is not None @@ -45,9 +49,11 @@ class SetPersonPrimarySite(Method): sites = Sites(self.api, [site_id_or_login_base]) if not sites: raise PLCInvalidArgument, "No such site" - site = sites[0] + if site['peer_id'] is not None: + raise PLCInvalidArgument, "Not a local site" + if site['site_id'] not in person['site_ids']: raise PLCInvalidArgument, "Not a member of the specified site"