- use Boot.notify_owners()
[plcapi.git] / PLC / Methods / GetPersons.py
index 4de3347..6ac93ee 100644 (file)
@@ -3,8 +3,11 @@ from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.Filter import Filter
 from PLC.Persons import Person, Persons
+from PLC.Sites import Site, Sites
 from PLC.Auth import Auth
 
+hidden_fields = ['password', 'verification_key', 'verification_expires']
+
 class GetPersons(Method):
     """
     Returns an array of structs containing details about users. If
@@ -29,13 +32,11 @@ class GetPersons(Method):
         ]
 
     # Filter out password field
-    can_return = lambda (field, value): field not in ['password']
-    return_fields = dict(filter(can_return, Person.fields.items()))
+    return_fields = dict(filter(lambda (field, value): field not in hidden_fields,
+                                Person.fields.items()))
     returns = [return_fields]
     
-
     def call(self, auth, person_filter = None, return_fields = None):
-
        # If we are not admin, make sure to only return viewable accounts
         if 'admin' not in self.caller['roles']:
             # Get accounts that we are able to view
@@ -53,8 +54,10 @@ class GetPersons(Method):
 
         # Filter out password field
         if return_fields:
-            while 'password' in return_fields:
-                return_fields.remove('password')
+            return_fields = filter(lambda field: field not in hidden_fields,
+                                   return_fields)
+       else:
+           return_fields = self.return_fields.keys()
 
         persons = Persons(self.api, person_filter, return_fields)