Skip to content

Commit

Permalink
Limit non job owners interaction
Browse files Browse the repository at this point in the history
Check user permissions before allowing a
user to "eat, kill, retry" jobs that they
do not own. Allow an override in
"File -> Enable Job Interaction". This gets
saved to the config file and is disabled by
default.
  • Loading branch information
roulaoregan-spi authored and DiegoTavares committed Aug 20, 2024
1 parent d72e094 commit 4bb1e0c
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 90 deletions.
2 changes: 2 additions & 0 deletions cuegui/cuegui/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def __packaged_version():
EMAIL_BODY_PREFIX = __config.get('email.body_prefix')
EMAIL_BODY_SUFFIX = __config.get('email.body_suffix')
EMAIL_DOMAIN = __config.get('email.domain')
USER_CONFIRM_RESTART = "You must restart for this action to take effect, close window?: "
USER_INTERACTION_PERMISSIONS = "You do not have permissions to {0} {1} owned by {2}"

GITHUB_CREATE_ISSUE_URL = __config.get('links.issue.create')
URL_USERGUIDE = __config.get('links.user_guide')
Expand Down
34 changes: 33 additions & 1 deletion cuegui/cuegui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(self, app_name, app_version, window_name, parent = None):
self.name = window_name
else:
self.name = self.windows_names[0]
self.__isEnabled = bool(int(QtGui.qApp.settings.value("EnableJobInteraction", 0)))

# Provides a location for widgets to the right of the menu
menuLayout = QtWidgets.QHBoxLayout()
Expand Down Expand Up @@ -195,6 +196,20 @@ def __createMenus(self):
self.windowMenu = self.menuBar().addMenu("&Window")
self.helpMenu = self.menuBar().addMenu("&Help")

if self.__isEnabled is False:
# Menu Bar: File -> Enable Job Interaction
enableJobInteraction = QtWidgets.QAction(QtGui.QIcon('icons/exit.png'), '&Enable Job Interaction', self)
enableJobInteraction.setStatusTip('Enable Job Interaction')
enableJobInteraction.triggered.connect(self.__enableJobInteraction)
self.fileMenu.addAction(enableJobInteraction)
# allow user to disable the job interaction
else:
# Menu Bar: File -> Disable Job Interaction
enableJobInteraction = QtWidgets.QAction(QtGui.QIcon('icons/exit.png'), '&Disable Job Interaction', self)
enableJobInteraction.setStatusTip('Disable Job Interaction')
enableJobInteraction.triggered.connect(self.__enableJobInteraction)
self.fileMenu.addAction(enableJobInteraction)

# Menu Bar: File -> Close Window
close = QtWidgets.QAction(QtGui.QIcon('icons/exit.png'), '&Close Window', self)
close.setStatusTip('Close Window')
Expand Down Expand Up @@ -454,9 +469,26 @@ def __revertLayout(self):
result = QtWidgets.QMessageBox.question(
self,
"Restart required ",
"You must restart for this action to take effect, close window?: ",
cuegui.Constants.USER_CONFIRM_RESTART,
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

if result == QtWidgets.QMessageBox.Yes:
self.settings.setValue("RevertLayout", True)
self.__windowCloseApplication()

def __enableJobInteraction(self):
""" Enable/Disable user job interaction """
result = QtWidgets.QMessageBox.question(
self,
"Job Interaction Settings ",
cuegui.Constants.USER_CONFIRM_RESTART,
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

if result == QtWidgets.QMessageBox.Yes:
# currently not enabled, user wants to enable
if self.__isEnabled is False:
self.settings.setValue("EnableJobInteraction", 1)
self.__windowCloseApplication()
else:
self.settings.setValue("EnableJobInteraction", 0)
self.__windowCloseApplication()
Loading

0 comments on commit 4bb1e0c

Please sign in to comment.