Status_bar: updated p-group selection. ongoigne ffort to fix bugs in abton system...
This commit is contained in:
@@ -471,55 +471,34 @@ class StatusBar(QStatusBar):
|
||||
|
||||
def _after_baton_granted_select_pgroup(self) -> None:
|
||||
"""
|
||||
After baton grant:
|
||||
- if exactly one allowed p-group, apply it automatically
|
||||
- otherwise prompt user to choose from their allowed list
|
||||
After baton grant, open the same p-group selection flow
|
||||
used everywhere else so staff and non-staff behave consistently.
|
||||
"""
|
||||
pgroups = [str(p).strip() for p in (self.__allowed_pgroups or []) if p is not None and str(p).strip()]
|
||||
if not pgroups:
|
||||
self.show_change_dialog()
|
||||
|
||||
def show_change_dialog(self):
|
||||
logger.debug(self.__decoded_token.pgroups)
|
||||
curr = self.__status.session.current_pgroup
|
||||
pgroups = [str(p) for p in (self.__allowed_pgroups or []) if p is not None and str(p).strip()]
|
||||
if self.__is_staff:
|
||||
def _on_loaded(lst: list):
|
||||
try:
|
||||
merged = {str(p).strip() for p in (lst or []) if p is not None and str(p).strip()}
|
||||
if not merged:
|
||||
merged = set(pgroups)
|
||||
self._generate_pgroup_dialogue(curr=curr, pgroups=sorted(merged))
|
||||
finally:
|
||||
try:
|
||||
self.staff_pgroups_loaded.disconnect(_on_loaded)
|
||||
except Exception as e:
|
||||
logger.debug(f"Error disconnecting: {e}")
|
||||
pass
|
||||
|
||||
self.staff_pgroups_loaded.connect(_on_loaded)
|
||||
self.__list_staff_pgroups()
|
||||
return
|
||||
|
||||
if len(pgroups) == 1:
|
||||
self.set_pgroup.emit(pgroups[0])
|
||||
return
|
||||
|
||||
default_pgroup = self._latest_pgroup(pgroups)
|
||||
curr = None
|
||||
if self.__status and self.__status.session:
|
||||
curr = self.__status.session.current_pgroup or default_pgroup
|
||||
|
||||
self._pgroup_dialog_for_baton = PGroupDialog(
|
||||
curr_pgroup=curr,
|
||||
pgroups=pgroups,
|
||||
parent=self,
|
||||
)
|
||||
selected_pgroup = self._pgroup_dialog_for_baton.get_input()
|
||||
if self._pgroup_dialog_for_baton.exec() == QDialog.DialogCode.Accepted:
|
||||
if selected_pgroup:
|
||||
self.set_pgroup.emit(selected_pgroup)
|
||||
|
||||
self._pgroup_dialog_for_baton = None
|
||||
|
||||
def _show_post_grant_pgroup_dialog(self, available_pgroups: list[str]) -> None:
|
||||
curr_pgroup = None
|
||||
if self.__status and self.__status.session:
|
||||
curr_pgroup = self.__status.session.current_pgroup
|
||||
|
||||
if self._pgroup_dialog_for_baton is not None and self._pgroup_dialog_for_baton.isVisible():
|
||||
return
|
||||
|
||||
self._pgroup_dialog_for_baton = PGroupDialog(
|
||||
curr_pgroup=curr_pgroup,
|
||||
pgroups=available_pgroups,
|
||||
parent=self
|
||||
)
|
||||
|
||||
if self._pgroup_dialog_for_baton.exec() == QDialog.DialogCode.Accepted:
|
||||
selected_pgroup = (self._pgroup_dialog_for_baton.get_input() or "").strip()
|
||||
if selected_pgroup:
|
||||
self.set_pgroup.emit(selected_pgroup)
|
||||
|
||||
self._pgroup_dialog_for_baton = None
|
||||
self._generate_pgroup_dialogue(curr=curr, pgroups=pgroups)
|
||||
|
||||
def _on_grab_clicked(self):
|
||||
"""Handle grab/request click - baton first, p-group after grant."""
|
||||
@@ -579,29 +558,3 @@ class StatusBar(QStatusBar):
|
||||
self._generate_pgroup_dialogue(curr=curr, pgroups=pgroups)
|
||||
return
|
||||
self.set_pgroup.emit(entered_text)
|
||||
|
||||
self.set_pgroup.emit(entered_text)
|
||||
|
||||
def show_change_dialog(self):
|
||||
logger.debug(self.__decoded_token.pgroups)
|
||||
curr = self.__status.session.current_pgroup
|
||||
pgroups = [str(p) for p in (self.__allowed_pgroups or []) if p is not None and str(p).strip()]
|
||||
if self.__is_staff:
|
||||
def _on_loaded(lst: list):
|
||||
try:
|
||||
merged = {str(p).strip() for p in (lst or []) if p is not None and str(p).strip()}
|
||||
if not merged:
|
||||
merged = set(pgroups)
|
||||
self._generate_pgroup_dialogue(curr=curr, pgroups=sorted(merged))
|
||||
finally:
|
||||
try:
|
||||
self.staff_pgroups_loaded.disconnect(_on_loaded)
|
||||
except Exception as e:
|
||||
logger.debug(f"Error disconnecting: {e}")
|
||||
pass
|
||||
|
||||
self.staff_pgroups_loaded.connect(_on_loaded)
|
||||
self.__list_staff_pgroups()
|
||||
return
|
||||
|
||||
self._generate_pgroup_dialogue(curr=curr, pgroups=pgroups)
|
||||
|
||||
Reference in New Issue
Block a user