remove falsy values from body
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Max Erenberg 2021-09-08 13:20:45 +00:00
parent 9f549ee58b
commit da3f1f49da
2 changed files with 8 additions and 3 deletions

View File

@ -29,6 +29,12 @@ def update_positions():
required = cfg.get('positions_required')
available = cfg.get('positions_available')
# remove falsy values
body = {
positions: username for positions, username in body.items()
if username
}
for position in body.keys():
if position not in available:
return {
@ -36,7 +42,7 @@ def update_positions():
}, 400
for position in required:
if not body.get(position):
if position not in body:
return {
'error': f'missing required position: {position}'
}, 400

View File

@ -28,8 +28,7 @@ class UpdateMemberPositionsTransaction(AbstractTransaction):
# Reverse the dict so it's easier to use (username -> positions)
self.positions = defaultdict(list)
for position, username in positions_reversed.items():
if username is not None:
self.positions[username].append(position)
self.positions[username].append(position)
# a cached Dict of the Users who need to be modified (username -> User)
self.users: Dict[str, IUser] = {}