mirror of
https://github.com/sartography/spiffworkflow-backend.git
synced 2025-02-24 21:38:22 +00:00
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""Get_env."""
|
|
from typing import Any
|
|
|
|
from spiffworkflow_backend.models.group import GroupModel
|
|
from spiffworkflow_backend.models.group import GroupNotFoundError
|
|
from spiffworkflow_backend.models.script_attributes_context import (
|
|
ScriptAttributesContext,
|
|
)
|
|
from spiffworkflow_backend.scripts.script import Script
|
|
|
|
|
|
class GetGroupMembers(Script):
|
|
"""GetGroupMembers."""
|
|
|
|
def get_description(self) -> str:
|
|
"""Get_description."""
|
|
return """Return the list of usernames of the users in the given group."""
|
|
|
|
def run(
|
|
self,
|
|
script_attributes_context: ScriptAttributesContext,
|
|
*args: Any,
|
|
**kwargs: Any,
|
|
) -> Any:
|
|
"""Run."""
|
|
group_identifier = args[0]
|
|
group = GroupModel.query.filter_by(identifier=group_identifier).first()
|
|
if group is None:
|
|
raise GroupNotFoundError(
|
|
f"Script 'get_group_members' could not find group with identifier '{group_identifier}'."
|
|
)
|
|
|
|
usernames = [u.username for u in group.users]
|
|
return usernames
|