mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
local settings can set admin permissions
This commit is contained in:
parent
97a2df90b5
commit
7099afcee2
2 changed files with 36 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import sys
|
||||
from Qt import QtWidgets, QtGui
|
||||
from .lib import is_password_required
|
||||
from .widgets import PasswordDialog
|
||||
from .local_settings import LocalSettingsWindow
|
||||
from .settings import (
|
||||
|
|
@ -30,6 +31,7 @@ def main(user_role=None):
|
|||
|
||||
|
||||
__all__ = (
|
||||
"is_password_required",
|
||||
"style",
|
||||
"PasswordDialog",
|
||||
"MainWidget",
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
import getpass
|
||||
|
||||
from Qt import QtWidgets
|
||||
from Qt import QtWidgets, QtCore
|
||||
from openpype.tools.settings import (
|
||||
is_password_required,
|
||||
PasswordDialog
|
||||
)
|
||||
|
||||
|
||||
class LocalGeneralWidgets(QtWidgets.QWidget):
|
||||
def __init__(self, parent):
|
||||
super(LocalGeneralWidgets, self).__init__(parent)
|
||||
|
||||
self._loading_local_settings = False
|
||||
|
||||
username_input = QtWidgets.QLineEdit(self)
|
||||
username_input.setPlaceholderText(getpass.getuser())
|
||||
|
||||
|
|
@ -24,6 +30,8 @@ class LocalGeneralWidgets(QtWidgets.QWidget):
|
|||
self.is_admin_input = is_admin_input
|
||||
|
||||
def update_local_settings(self, value):
|
||||
self._loading_local_settings = True
|
||||
|
||||
username = ""
|
||||
is_admin = False
|
||||
if value:
|
||||
|
|
@ -35,8 +43,28 @@ class LocalGeneralWidgets(QtWidgets.QWidget):
|
|||
if self.is_admin_input.isChecked() != is_admin:
|
||||
self.is_admin_input.setChecked(is_admin)
|
||||
|
||||
self._loading_local_settings = False
|
||||
|
||||
def _on_admin_check_change(self):
|
||||
self.is_admin_input.setChecked(False)
|
||||
if self._loading_local_settings:
|
||||
return
|
||||
|
||||
if not self.is_admin_input.isChecked():
|
||||
return
|
||||
|
||||
if not is_password_required():
|
||||
return
|
||||
|
||||
dialog = PasswordDialog(self)
|
||||
dialog.setModal(True)
|
||||
dialog.exec_()
|
||||
result = dialog.result()
|
||||
if self.is_admin_input.isChecked() != result:
|
||||
if result:
|
||||
state = QtCore.Qt.Checked
|
||||
else:
|
||||
state = QtCore.Qt.Unchecked
|
||||
self.is_admin_input.setCheckState(state)
|
||||
|
||||
def settings_value(self):
|
||||
# Add changed
|
||||
|
|
@ -45,6 +73,8 @@ class LocalGeneralWidgets(QtWidgets.QWidget):
|
|||
username = self.username_input.text()
|
||||
if username:
|
||||
output["username"] = username
|
||||
# Do not return output yet since we don't have mechanism to save or
|
||||
# load these data through api calls
|
||||
|
||||
is_admin = self.is_admin_input.isChecked()
|
||||
if is_admin:
|
||||
output["is_admin"] = is_admin
|
||||
return output
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue