Implement TUI support for multiple users in each position #80

Merged
merenber merged 6 commits from feature-59 into master 2023-01-23 02:26:15 -05:00
3 changed files with 8 additions and 3 deletions
Showing only changes of commit d16e7bb293 - Show all commits

View File

@ -8,6 +8,10 @@ import ceo.tui.utils as tui_utils
from ceo.tui.views import TransactionView
from ceod.transactions.members import UpdateMemberPositionsTransaction
from ceo_common.logger_factory import logger_factory
logger = logger_factory(__name__)
class SetPositionsController(Controller):
def __init__(self, model, app):
@ -18,6 +22,7 @@ class SetPositionsController(Controller):
for pos, field in self.view.position_fields.items():
if field.edit_text != '':
body[pos] = field.edit_text
logger.info(body)
model = TransactionModel(
UpdateMemberPositionsTransaction.operations,
'POST', '/api/positions', json=body

View File

@ -35,7 +35,7 @@ def update_positions():
# remove falsy values and parse multiple users in each position
# Example: "user1,user2, user3" -> ["user1","user2","user3"]
body = {
positions: username.replace(' ','').split(',') for positions, username in body.items()
positions: username.replace(' ', '').split(',') for positions, username in body.items()
if username
}

View File

@ -21,7 +21,7 @@ class UpdateMemberPositionsTransaction(AbstractTransaction):
'subscribe_to_mailing_lists',
]
def __init__(self, positions_reversed: Dict[str, Union[str,list]]):
def __init__(self, positions_reversed: Dict[str, Union[str, list]]):
# positions_reversed is position -> username
super().__init__()
self.ldap_srv = component.getUtility(ILDAPService)
@ -36,7 +36,7 @@ class UpdateMemberPositionsTransaction(AbstractTransaction):
self.positions[user].append(position)
else:
raise TypeError("Username(s) under each position must either be a string or a list")
# a cached Dict of the Users who need to be modified (username -> User)
self.users: Dict[str, IUser] = {}