From 19ba092340e4b38c1a32302fd1c76da3762c32df Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 26 Jul 2022 16:56:19 +0200 Subject: [PATCH] Add property of whether the printer details can be read We'd assume so, but there is a permissions node for it. If it can't be read by the user, they can't navigate to the printer's overview page. So we should hide the button then. Contributes to issue CURA-9220. --- plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py | 7 +++++++ .../src/UltimakerNetworkedPrinterOutputDevice.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index a4b022d1e7..6431d09b7b 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -366,6 +366,13 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): """ return "digital-factory.print-job.write.own" in self._account.permissions + @pyqtProperty(bool, constant = True) + def canReadPrinterDetails(self) -> bool: + """ + Whether this user can read the status of the printer. + """ + return "digital-factory.printer.read" in self._account.permissions + @property def clusterData(self) -> CloudClusterResponse: """Gets the cluster response from which this device was created.""" diff --git a/plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py index e928e4f2ef..8f25df37db 100644 --- a/plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py @@ -213,6 +213,13 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice): """ return True + @pyqtProperty(bool, constant = True) + def canReadPrinterDetails(self) -> bool: + """ + Whether this user can read the status of the printer. + """ + return True + @pyqtSlot(name="openPrintJobControlPanel") def openPrintJobControlPanel(self) -> None: raise NotImplementedError("openPrintJobControlPanel must be implemented")