- added 'message' instance variable (high level description of this event)
[plcapi.git] / PLC / Methods / UpdatePerson.py
index 65a490f..85c4a71 100644 (file)
@@ -40,9 +40,10 @@ class UpdatePerson(Method):
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
-
         person = persons[0]
-       PLCCheckLocalPerson(person,"UpdatePerson")
+
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
         # Authenticated function
         assert self.caller is not None
@@ -53,6 +54,16 @@ class UpdatePerson(Method):
 
         person.update(person_fields)
         person.sync()
+       
+       # Logging variables
        self.object_ids = [person['person_id']]
 
+        # Redact password
+        if 'password' in person_fields:
+            person_fields['password'] = "Removed by API"
+        self.message = 'Person %d updated: %s.' % \
+                       (person['person_id'], person_fields.keys())
+       if 'enabled' in person_fields:
+            self.message += ' Person enabled'  
+
         return 1