Make changes to the way actions work

This commit is contained in:
Marek Wolan
2023-08-28 22:34:20 +01:00
parent a9e969aa13
commit 319e87d200
8 changed files with 83 additions and 70 deletions

View File

@@ -85,17 +85,6 @@ class DomainController(SimComponent):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.action_manager = ActionManager()
# Action 'account' matches requests like:
# ['account', '<account-uuid>', *account_action]
self.action_manager.add_action(
"account",
Action(
func=lambda request, context: self.accounts[request.pop(0)].apply_action(request, context),
validator=GroupMembershipValidator([AccountGroup.DOMAIN_ADMIN]),
),
)
def describe_state(self) -> Dict:
"""
Produce a dictionary describing the current state of this object.
@@ -109,6 +98,19 @@ class DomainController(SimComponent):
state.update({"accounts": {uuid: acct.describe_state() for uuid, acct in self.accounts.items()}})
return state
def _init_action_manager(self) -> ActionManager:
am = super()._init_action_manager()
# Action 'account' matches requests like:
# ['account', '<account-uuid>', *account_action]
am.add_action(
"account",
Action(
func=lambda request, context: self.accounts[request.pop(0)].apply_action(request, context),
validator=GroupMembershipValidator([AccountGroup.DOMAIN_ADMIN]),
),
)
return am
def _register_account(self, account: Account) -> None:
"""TODO."""
...