add GetSliceTicket
[plcapi.git] / PLC / Methods / AdmGetPersonSites.py
index 161042c..79324f8 100644 (file)
@@ -3,10 +3,12 @@ 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.Auth import Auth
 
 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,17 @@ class AdmGetPersonSites(Method):
     themselves and others at their sites.
     """
 
+    status = "deprecated"
+
     roles = ['admin', 'pi', 'user', 'tech']
 
     accepts = [
-        PasswordAuth(),
+        Auth(),
         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
@@ -31,7 +35,7 @@ class AdmGetPersonSites(Method):
         if not persons:
             raise PLCInvalidArgument, "No such account"
 
-        person = persons.values()[0]
+        person = persons[0]
 
         # Authenticated function
         assert self.caller is not None
@@ -40,10 +44,4 @@ class AdmGetPersonSites(Method):
         if not self.caller.can_view(person):
             raise PLCPermissionDenied, "Not allowed to view specified account"
 
-        # Filter out deleted sites
-        # XXX This shouldn't be necessary once the join tables are cleaned up
-        if person['site_ids']:
-            sites = Sites(self.api, person['site_ids'])
-            return filter(lambda site_id: site_id in sites, person['site_ids'])
-
         return person['site_ids']