merge changes from head
[plcapi.git] / PLC / Methods / DeletePCU.py
index ae52b43..0d7a09a 100644 (file)
@@ -2,7 +2,7 @@ from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.PCUs import PCU, PCUs
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
 
 class DeletePCU(Method):
     """
@@ -16,15 +16,16 @@ class DeletePCU(Method):
     roles = ['admin', 'pi', 'tech']
 
     accepts = [
-        PasswordAuth(),
+        Auth(),
         PCU.fields['pcu_id'],
         ]
 
     returns = Parameter(int, '1 if successful')
 
+
     def call(self, auth, pcu_id):
         # Get associated PCU details
-        pcus = PCUs(self.api, [pcu_id]).values()
+        pcus = PCUs(self.api, [pcu_id])
         if not pcus:
             raise PLCInvalidArgument, "No such PCU"
         pcu = pcus[0]
@@ -34,5 +35,9 @@ class DeletePCU(Method):
                 raise PLCPermissionDenied, "Not allowed to update that PCU"
 
         pcu.delete()
+       
+       # Logging variables
+       self.object_ids = [pcu['pcu_id']]
+       self.message = 'PCU %d deleted' % pcu['pcu_id']
 
         return 1