- re-enable return_fields specification
[plcapi.git] / PLC / Methods / AdmGetPowerControlUnitNodes.py
index 9bd48f5..af298ee 100644 (file)
@@ -2,10 +2,9 @@ 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.Methods.GetPCUs import GetPCUs
+from PLC.Auth import Auth
 
-class AdmGetPowerControlUnitNodes(GetPCUs):
+class AdmGetPowerControlUnitNodes(Method):
     """
     Deprecated. See GetPCUs.
 
@@ -16,10 +15,12 @@ class AdmGetPowerControlUnitNodes(GetPCUs):
     their sites.
     """
 
+    status = "deprecated"
+
     roles = ['admin', 'pi', 'tech']
 
     accepts = [
-        PasswordAuth(),
+        Auth(),
         PCU.fields['pcu_id']
         ]
 
@@ -27,10 +28,14 @@ class AdmGetPowerControlUnitNodes(GetPCUs):
                 'port_number': Parameter(int, "Port number")}]
 
     def call(self, auth, pcu_id):
-        pcus = GetPCUs.call(self, auth, [pcu_id])
+        pcus = PCUs(self.api, [pcu_id])
         if not pcus:
             raise PLCInvalidArgument, "No such PCU"
         pcu = pcus[0]
 
+        if 'admin' not in self.caller['roles']:
+            if pcu['site_id'] not in self.caller['site_ids']:
+                raise PLCPermissionDenied, "Not allowed to view that PCU"
+
         return [{'node_id': node_id, 'port_number': port} \
                 for (node_id, port) in zip(pcu['node_ids'], pcu['ports'])]