Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/user_interaction/manage_users_conf.py
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2022-06-14 22:38:39 +1000
committerGitHub <noreply@github.com>2022-06-14 14:38:39 +0200
commit5c3c1312a49e1c110d4c5825fbb8242868544900 (patch)
tree4dddbd849c5ea7d5a128f126849bc450bc69cda6 /archinstall/lib/user_interaction/manage_users_conf.py
parent86531ef62f777f91ef2f4ca7d102abdfccb11ded (diff)
Update list manager (#1331)
* Rework partition management * Update * Update list manager * Update * Update Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
Diffstat (limited to 'archinstall/lib/user_interaction/manage_users_conf.py')
-rw-r--r--archinstall/lib/user_interaction/manage_users_conf.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/archinstall/lib/user_interaction/manage_users_conf.py b/archinstall/lib/user_interaction/manage_users_conf.py
index 33c31342..a97328c2 100644
--- a/archinstall/lib/user_interaction/manage_users_conf.py
+++ b/archinstall/lib/user_interaction/manage_users_conf.py
@@ -25,7 +25,7 @@ class UserList(ListManager):
str(_('Promote/Demote user')),
str(_('Delete User'))
]
- super().__init__(prompt, lusers, self._actions, self._actions[0])
+ super().__init__(prompt, lusers, [self._actions[0]], self._actions[1:])
def reformat(self, data: List[User]) -> Dict[str, User]:
table = FormattedOutput.as_table(data)
@@ -45,27 +45,25 @@ class UserList(ListManager):
def selected_action_display(self, user: User) -> str:
return user.username
- def exec_action(self, data: List[User]) -> List[User]:
- active_user = self.target if self.target else None
-
- if self.action == self._actions[0]: # add
+ def handle_action(self, action: str, entry: Optional[User], data: List[User]) -> List[User]:
+ if action == self._actions[0]: # add
new_user = self._add_user()
if new_user is not None:
# in case a user with the same username as an existing user
# was created we'll replace the existing one
data = [d for d in data if d.username != new_user.username]
data += [new_user]
- elif self.action == self._actions[1]: # change password
- prompt = str(_('Password for user "{}": ').format(active_user.username))
+ elif action == self._actions[1]: # change password
+ prompt = str(_('Password for user "{}": ').format(entry.username))
new_password = get_password(prompt=prompt)
if new_password:
- user = next(filter(lambda x: x == active_user, data), 1)
+ user = next(filter(lambda x: x == entry, data), 1)
user.password = new_password
- elif self.action == self._actions[2]: # promote/demote
- user = next(filter(lambda x: x == active_user, data), 1)
+ elif action == self._actions[2]: # promote/demote
+ user = next(filter(lambda x: x == entry, data), 1)
user.sudo = False if user.sudo else True
- elif self.action == self._actions[3]: # delete
- data = [d for d in data if d != active_user]
+ elif action == self._actions[3]: # delete
+ data = [d for d in data if d != entry]
return data